4. Project Opinions

This section goes through the assumptions we made in the project structure and project properties.

4.1 Cloud Foundry Project Opinions

We take the following opinionated decisions for a Cloud Foundry based project:

  • The application is built by using the Maven or Gradle wrapper.
  • The application is deployed to Cloud Foundry.
  • Your application needs a manifest.yml Cloud Foundry descriptor.
  • For the Maven (example project), we assume:

    • Usage of the Maven Wrapper.
    • settings.xml is parametrized to pass the credentials to push code to Artifactory:

      • M2_SETTINGS_REPO_ID contains the server ID for Artifactory or Nexus deployment.
      • M2_SETTINGS_REPO_USERNAME contains the username for Artifactory or Nexus deployment.
      • M2_SETTINGS_REPO_PASSWORD contains the password for Artifactory or Nexus deployment.
    • Artifacts are deployed by ./mvnw clean deploy.
    • We use the stubrunner.ids property to retrieve list of collaborators for which stubs should be downloaded.
    • repo.with.binaries property (injected by the pipeline): Contains the URL to the repo containing binaries (for example, Artifactory).
    • distribution.management.release.id property (injected by the pipeline): Contains the ID of the distribution management. It corresponds to server ID in settings.xml.
    • distribution.management.release.url property (injected by the pipeline): Contains the URL of the repository that contains binaries (for example, Artifactory).
    • Running API compatibility tests with the apicompatibility Maven profile.
    • latest.production.version property (injected by the pipeline): Contains the latest production version for the repo (retrieved from Git tags).
    • Running smoke tests on a deployed app with the smoke Maven profile.
    • Running end to end tests on a deployed app with the e2e Maven profile.
  • For Gradle (example project check the gradle/pipeline.gradle file), we assume:

    • Usage of the Gradlew Wrapper.
    • A deploy task for artifact deployment.
    • The REPO_WITH_BINARIES_FOR_UPLOAD environment variable (Injected by the pipeline) contains the URL to the repository that contains binaries (for example, Artifactory).
    • The M2_SETTINGS_REPO_USERNAME environment variable contains the user name used to send the binary to the repository that contains binaries (for exampl,e Artifactory).
    • The M2_SETTINGS_REPO_PASSWORD environment variable contains the password used to send the binary to the repository that contains binaries (for example, Artifactory).
    • Running API compatibility tests with the apiCompatibility task.
    • latestProductionVersion property (injected by the pipeline): Contains the latest production version for the repository (retrieved from Git tags).
    • Running smoke tests on a deployed app with the smoke task.
    • Running end to end tests on a deployed app with the e2e task.
    • groupId task to retrieve the group ID.
    • artifactId task to retrieve the artifact ID.
    • currentVersion task to retrieve the current version.
    • stubIds task to retrieve the list of collaborators for which stubs should be downloaded.
  • For PHP (example project), we asssume:

    • Usage of Composer.
    • composer install is called to fetch libraries.
    • The whole application is compressed to tar.gz and uploaded to binary storage.

      • REPO_WITH_BINARIES_FOR_UPLOAD environment variable (injected by the pipeline): Contains the URL of the repository that contains binaries (for example, Artifactory)
      • The M2_SETTINGS_REPO_USERNAME environment variable contains the user name used to send the binary to the repo containing binaries (for example, Artifactory).
      • The M2_SETTINGS_REPO_PASSWORD environment variable contains the password used to send the binary to the repo containing binaries (for example, Artifactory).
    • group-id: Composer task that echoes the group ID.
    • app-name: Composer task that echoes application name.
    • stub-ids: Composer task that echoes stub runner ids.
    • test-apicompatibility: Composer task that is executed for api compatibility tests.
    • test-smoke: Composer task that is executed for smoke testing (the APPLICATION_URL and STUBRUNNER_URL environment variables are available here to be used).
    • test-e2e: Composer task that is executed for end-to-end testing (APPLICATION_URL env vars is available here to be used)
    • target is assumed to be the output folder. Put it in .gitignore
  • For NodeJS (example project), we assume:

    • Usage of npm
    • npm install is called to fetch libraries.
    • npm test is called to run tests.
    • npm run group-id: npm task that echoes the group ID.
    • npm run app-name: npm task that echoes application name.
    • npm run stub-ids: npm task that echoes stub runner IDs.
    • npm run test-apicompatibility: npm task that is executed for api compatibility tests.
    • npm run test-smoke: npm task that is executed for smoke testing.
    • npm run test-e2e: npm task that is executed for end-to-end testing.
    • target is assumed to be the output folder. Put it in .gitignore
  • For .Net (example project):

    • Usage of ASP.NET core
    • dotnet build is called to build the project.
    • dotnet msbuild /nologo /t:CFPUnitTests is called to run unit tests.
    • dotnet msbuild /nologo /t:CFPIntegrationTests is called to run integration tests.
    • dotnet msbuild /nologo /t:CFPPublish /p:Configuration=Release is called to publish a ZIP with a self-contained DLL, together with all manifests and deployment files.
    • dotnet msbuild /nologo /t:CFPGroupId is the npm task that echos the group ID.
    • dotnet msbuild /nologo /t:CFPAppName is the npm task that echos application name.
    • dotnet msbuild /nologo /t:CFPStubIds is the npm task that echos stub runner IDs.
    • dotnet msbuild /nologo /t:CFPApiCompatibilityTest is run for API compatibility tests.
    • dotnet msbuild /nologo /t:CFPSmokeTests is executed for smoke testing.
    • dotnet msbuild /nologo /t:CFPE2eTests is executed for end-to-end testing.
    • target is assumed to be the output folder. Add it to .gitignore.

4.2 Kubernetes Project Opinions

We use the following opinionated decisions for a Cloud Foundry based project:

  • The application is built by using the Maven or Gradle wrappers.
  • The application is deployed to Kubernetes.
  • The Java Docker image needs to allow passing of system properties through the SYSTEM_PROPS environment variable.
  • For Maven (example project), we assume:

    • Usage of the Maven Wrapper.
    • settings.xml is parametrized to pass the credentials to push code to Artifactory and Docker repositories:

      • M2_SETTINGS_REPO_ID: Server ID for Artifactory or Nexus deployment.
      • M2_SETTINGS_REPO_USERNAME: User name for Artifactory or Nexus deployment.
      • M2_SETTINGS_REPO_PASSWORD: Password for Artifactory or Nexus deployment.
      • DOCKER_SERVER_ID: Server ID for Docker image pushing.
      • DOCKER_USERNAME: User name for Docker image pushing.
      • DOCKER_PASSWORD: Password for Docker image pushing.
      • DOCKER_EMAIL: Email for Artifactory or Nexus deployment
    • DOCKER_REGISTRY_URL environment variable: Contains (Overridable - defaults to DockerHub) URL of the Docker registry.
    • DOCKER_REGISTRY_ORGANIZATION environment variable: Contains the organization where your Docker repository resides.
    • Artifacts and Docker image deployment is done by using ./mvnw clean deploy.
    • stubrunner.ids property: To retrieve list of collaborators for which stubs should be downloaded.
    • repo.with.binaries property (injected by the pipeline): Contains the URL to the repo containing binaries (for example, Artifactory).
    • distribution.management.release.id property (injected by the pipeline): Contains the ID of the distribution management. Corresponds to the server ID in settings.xml
    • distribution.management.release.url property (injected by the pipeline): Contains the URL or the repository that contains binaries (for example, Artifactory).
    • deployment.yml contains the Kubernetes deployment descriptor.
    • service.yml contains the Kubernetes service descriptor.
    • running API compatibility tests with the apicompatibility Maven profile.
    • latest.production.version property (injected by the pipeline): Contains the latest production version for the repository (retrieved from Git tags).
    • Running smoke tests on a deployed app with the smoke Maven profile.
    • Running end to end tests on a deployed app with the e2e Maven profile.
  • For Gradle (example project check the gradle/pipeline.gradle file), we assume:

    • Usage of the Gradlew Wrapper.
    • deploy task for artifact deployment.
    • REPO_WITH_BINARIES_FOR_UPLOAD env var (injected by the pipeline): Contains the URL to the repository that contains binaries (for example, Artifactory).
    • M2_SETTINGS_REPO_USERNAME environment variable: User name used to send the binary to the repository that contains binaries (for example, Artifactory).
    • M2_SETTINGS_REPO_PASSWORD environment variable: Password used to send the binary to the repository that contains binaries (for example, Artifactory).
    • DOCKER_REGISTRY_URL environment variable: (Overridable - defaults to DockerHub) URL of the Docker registry.
    • DOCKER_USERNAME environment variable: User name used to send the the Docker image.
    • DOCKER_PASSWORD environment variable: Password used to send the the Docker image.
    • DOCKER_EMAIL environment variable: Email used to send the the Docker image.
    • DOCKER_REGISTRY_ORGANIZATION environment variable: Contains the organization where your Docker repo resides.
    • deployment.yml contains the Kubernetes deployment descriptor.
    • service.yml contains the Kubernetes service descriptor.
    • Running API compatibility tests with the apiCompatibility task.
    • latestProductionVersion property (injected by the pipeline): Contains the latest production version for the repositoryi (retrieved from Git tags).
    • Running smoke tests on a deployed application with the smoke task.
    • Running end to end tests on a deployed application with the e2e task.
    • groupId task to retrieve group ID.
    • artifactId task to retrieve artifact ID.
    • currentVersion task to retrieve the current version.
    • stubIds task to retrieve the list of collaborators for which stubs should be downloaded.