Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Abstracted CF / JVM / GRADLE & MAVEN
Browse files Browse the repository at this point in the history
this is the initial step that needed to be taken to complete #63. With this change, each platform / deployment approach will have its own file in which certain functions need to be implemented.
  • Loading branch information
marcingrzejszczak committed Jul 4, 2017
1 parent 78876c7 commit 5cd5bf7
Show file tree
Hide file tree
Showing 34 changed files with 1,523 additions and 1,288 deletions.
58 changes: 29 additions & 29 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -522,29 +522,29 @@ If `fly` is properly installed then it should print out the version.

- `app-url` - url pointing to your forked `github-webhook` repo
- `github-private-key` - your private key to clone / tag GitHub repos
- `repo-with-jars` - the IP is set to the defaults for Docker Machine. You should update it to point to your setup
- `repo-with-binaries` - the IP is set to the defaults for Docker Machine. You should update it to point to your setup

If you don't have a Docker Machine just execute `./whats_my_ip.sh` script to
get an external IP that you can pass to your `repo-with-jars` instead of the default
get an external IP that you can pass to your `repo-with-binaries` instead of the default
Docker Machine IP.

Below you can see what environment variables are required by the scripts. To the right hand side you can see the default values for PCF Dev that we set in the `credentials-sample.yml`.

[frame="topbot",options="header,footer"]
|======================
|Property Name | Property Description | Default value
|CF_TEST_API_URL | The URL to the CF Api for TEST env| api.local.pcfdev.io
|CF_STAGE_API_URL | The URL to the CF Api for STAGE env | api.local.pcfdev.io
|CF_PROD_API_URL | The URL to the CF Api for PROD env | api.local.pcfdev.io
|CF_TEST_ORG | Name of the org for the test env | pcfdev-org
|CF_TEST_SPACE | Name of the space for the test env | pcfdev-space
|CF_STAGE_ORG | Name of the org for the stage env | pcfdev-org
|CF_STAGE_SPACE | Name of the space for the stage env | pcfdev-space
|CF_PROD_ORG | Name of the org for the prod env | pcfdev-org
|CF_PROD_SPACE | Name of the space for the prod env | pcfdev-space
|REPO_WITH_JARS | URL to repo with the deployed jars | http://192.168.99.100:8081/artifactory/libs-release-local
|PAAS_TEST_API_URL | The URL to the CF Api for TEST env| api.local.pcfdev.io
|PAAS_STAGE_API_URL | The URL to the CF Api for STAGE env | api.local.pcfdev.io
|PAAS_PROD_API_URL | The URL to the CF Api for PROD env | api.local.pcfdev.io
|PAAS_TEST_ORG | Name of the org for the test env | pcfdev-org
|PAAS_TEST_SPACE | Name of the space for the test env | pcfdev-space
|PAAS_STAGE_ORG | Name of the org for the stage env | pcfdev-org
|PAAS_STAGE_SPACE | Name of the space for the stage env | pcfdev-space
|PAAS_PROD_ORG | Name of the org for the prod env | pcfdev-org
|PAAS_PROD_SPACE | Name of the space for the prod env | pcfdev-space
|REPO_WITH_BINARIES | URL to repo with the deployed jars | http://192.168.99.100:8081/artifactory/libs-release-local
|M2_SETTINGS_REPO_ID | The id of server from Maven settings.xml | artifactory-local
|CF_HOSTNAME_UUID | Additional suffix for the route. In a shared environment the default routes can be already taken |
|PAAS_HOSTNAME_UUID | Additional suffix for the route. In a shared environment the default routes can be already taken |
|APP_MEMORY_LIMIT | How much memory should be used by the infra apps (Eureka, Stub Runner etc.) | 256m
|JAVA_BUILDPACK_URL | The URL to the Java buildpack to be used by CF | https://github.com/cloudfoundry/java-buildpack.git#v3.8.1
|BUILD_OPTIONS | Additional options you would like to pass to the Maven / Gradle build |
Expand Down Expand Up @@ -1111,7 +1111,7 @@ Example screen:

image::{jenkins-root-docs}/seed.png[]

In the screenshot we could parametrize the `REPOS` and `REPO_WITH_JARS` params.
In the screenshot we could parametrize the `REPOS` and `REPO_WITH_BINARIES` params.

===== Global envs

Expand All @@ -1131,22 +1131,22 @@ The env vars that are used in all of the jobs are as follows:
[frame="topbot",options="header,footer"]
|======================
|Property Name | Property Description | Default value
|CF_TEST_API_URL | The URL to the CF Api for TEST env| api.local.pcfdev.io
|CF_STAGE_API_URL | The URL to the CF Api for STAGE env | api.local.pcfdev.io
|CF_PROD_API_URL | The URL to the CF Api for PROD env | api.local.pcfdev.io
|CF_TEST_ORG | Name of the org for the test env | pcfdev-org
|CF_TEST_SPACE | Name of the space for the test env | pcfdev-space
|CF_STAGE_ORG | Name of the org for the stage env | pcfdev-org
|CF_STAGE_SPACE | Name of the space for the stage env | pcfdev-space
|CF_PROD_ORG | Name of the org for the prod env | pcfdev-org
|CF_PROD_SPACE | Name of the space for the prod env | pcfdev-space
|REPO_WITH_JARS | URL to repo with the deployed jars | http://artifactory:8081/artifactory/libs-release-local
|PAAS_TEST_API_URL | The URL to the CF Api for TEST env| api.local.pcfdev.io
|PAAS_STAGE_API_URL | The URL to the CF Api for STAGE env | api.local.pcfdev.io
|PAAS_PROD_API_URL | The URL to the CF Api for PROD env | api.local.pcfdev.io
|PAAS_TEST_ORG | Name of the org for the test env | pcfdev-org
|PAAS_TEST_SPACE | Name of the space for the test env | pcfdev-space
|PAAS_STAGE_ORG | Name of the org for the stage env | pcfdev-org
|PAAS_STAGE_SPACE | Name of the space for the stage env | pcfdev-space
|PAAS_PROD_ORG | Name of the org for the prod env | pcfdev-org
|PAAS_PROD_SPACE | Name of the space for the prod env | pcfdev-space
|REPO_WITH_BINARIES | URL to repo with the deployed jars | http://artifactory:8081/artifactory/libs-release-local
|M2_SETTINGS_REPO_ID | The id of server from Maven settings.xml | artifactory-local
|JDK_VERSION | The name of the JDK installation | jdk8
|PIPELINE_VERSION | What should be the version of the pipeline (ultimately also version of the jar) | 1.0.0.M1-${GROOVY,script ="new Date().format('yyMMdd_HHmmss')"}-VERSION
|GIT_EMAIL | The email used by Git to tag repo | email@example.com
|GIT_NAME | The name used by Git to tag repo | Pivo Tal
|CF_HOSTNAME_UUID | Additional suffix for the route. In a shared environment the default routes can be already taken |
|PAAS_HOSTNAME_UUID | Additional suffix for the route. In a shared environment the default routes can be already taken |
|AUTO_DEPLOY_TO_STAGE | Should deployment to stage be automatic | false
|AUTO_DEPLOY_TO_PROD | Should deployment to prod be automatic | false
|ROLLBACK_STEP_REQUIRED | Should rollback step be present | true
Expand Down Expand Up @@ -1191,10 +1191,10 @@ In your scripts we reference the credentials via IDs. These are the defaults for
|======================
|Property Name | Property Description | Default value
|GIT_CREDENTIAL_ID | Credential ID used to tag a git repo | git
|REPO_WITH_JARS_CREDENTIALS_ID | Credential ID used for the repo with jars | repo-with-jars
|CF_TEST_CREDENTIAL_ID | Credential ID for CF Test env access | cf-test
|CF_STAGE_CREDENTIAL_ID | Credential ID for CF Stage env access | cf-stage
|CF_PROD_CREDENTIAL_ID | Credential ID for CF Prod env access | cf-prod
|REPO_WITH_BINARIES_CREDENTIALS_ID | Credential ID used for the repo with jars | repo-with-binaries
|PAAS_TEST_CREDENTIAL_ID | Credential ID for CF Test env access | cf-test
|PAAS_STAGE_CREDENTIAL_ID | Credential ID for CF Stage env access | cf-stage
|PAAS_PROD_CREDENTIAL_ID | Credential ID for CF Prod env access | cf-prod
|======================

If you already have in your system a credential to for example tag a repo
Expand Down
31 changes: 22 additions & 9 deletions common/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ The logic behind the deployment pipeline is written using Bash scripts.
----
.
├── build_and_upload.sh
├── build_api_compatibility_check.sh
├── pipeline-cf.sh
├── pipeline.sh
├── prod_complete.sh
├── prod_deploy.sh
├── projectType
│   ├── pipeline-gradle.sh
│   ├── pipeline-jvm.sh
│   └── pipeline-maven.sh
├── stage_deploy.sh
├── stage_e2e.sh
├── test_deploy.sh
Expand All @@ -19,18 +25,25 @@ The logic behind the deployment pipeline is written using Bash scripts.
└── test_smoke.sh
----

There is one script called `pipeline.sh` that contains all the functions
reused by other scripts.
Spring Cloud Pipelines is built on top of conventions. Here's how they look like:

Every other script represents the logic required to perform a step in the
pipeline.
There is one script called `pipeline.sh` that contains all required functions
necessary to be implemented by any other scripts.

Currently the flow looks like this:
=== Supported platforms

*Build phase*
In terms of platforms we support the convention looks as follows: `pipeline-${plaform}.sh`,
for example `pipeline-cf.sh` for Cloud Foundry implementations.

`build and upload -> `
=== Supported building tools

*Test phase*
Currently we support only JVM based applications via `projectType/pipeline-jvm.sh` and
building tools like Gradle and Maven (via `projectType/pipeline-gradle.sh` and
`projectType/pipeline-maven.sh`).

`test deploy -> test smoke -> test rollback smoke
=== Customizations

In order to add a new platform (e.g. `aaa` platform) it's enough to create a new file called
`pipeline-aaa.sh` and implement all functions present in the `pipeline.sh` file. Also
you'll need to pass the `PAAS_TYPE=aaa` env variable to the bash scripts so that
files get properly sourced.
23 changes: 3 additions & 20 deletions common/src/main/bash/build_and_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,9 @@ set -o errexit

__DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export ENVIRONMENT=BUILD

[[ -f "${__DIR}/pipeline.sh" ]] && source "${__DIR}/pipeline.sh" || \
echo "No pipeline.sh found"

echo "Additional Build Options [${BUILD_OPTIONS}]"
echo "Repo with jars [${REPO_WITH_JARS}]"

if [[ "${PROJECT_TYPE}" == "MAVEN" ]]; then
./mvnw versions:set -DnewVersion=${PIPELINE_VERSION} ${BUILD_OPTIONS}
if [[ "${CI}" == "CONCOURSE" ]]; then
./mvnw clean verify deploy -Ddistribution.management.release.id=${M2_SETTINGS_REPO_ID} -Ddistribution.management.release.url=${REPO_WITH_JARS} ${BUILD_OPTIONS} || ( $( printTestResults ) && return 1)
else
./mvnw clean verify deploy -Ddistribution.management.release.id=${M2_SETTINGS_REPO_ID} -Ddistribution.management.release.url=${REPO_WITH_JARS} ${BUILD_OPTIONS}
fi
elif [[ "${PROJECT_TYPE}" == "GRADLE" ]]; then
if [[ "${CI}" == "CONCOURSE" ]]; then
./gradlew clean build deploy -PnewVersion=${PIPELINE_VERSION} -DREPO_WITH_JARS=${REPO_WITH_JARS} ${BUILD_OPTIONS} --stacktrace || ( $( printTestResults ) && return 1)
else
./gradlew clean build deploy -PnewVersion=${PIPELINE_VERSION} -DREPO_WITH_JARS=${REPO_WITH_JARS} ${BUILD_OPTIONS} --stacktrace
fi
else
echo "Unsupported project build tool"
return 1
fi
build
34 changes: 3 additions & 31 deletions common/src/main/bash/build_api_compatibility_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,9 @@ set -o errexit

__DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export ENVIRONMENT=BUILD

[[ -f "${__DIR}/pipeline.sh" ]] && source "${__DIR}/pipeline.sh" || \
echo "No pipeline.sh found"

echo "Running retrieval of group and artifactid to download all dependencies. It might take a while..."
projectGroupId=$( retrieveGroupId )
projectArtifactId=$( retrieveArtifactId )

# Find latest prod version
LATEST_PROD_TAG=$( findLatestProdTag )
echo "Last prod tag equals ${LATEST_PROD_TAG}"
if [[ -z "${LATEST_PROD_TAG}" ]]; then
echo "No prod release took place - skipping this step"
else
# Downloading latest jar
LATEST_PROD_VERSION=${LATEST_PROD_TAG#prod/}
echo "Last prod version equals ${LATEST_PROD_VERSION}"
echo "Additional Build Options [${BUILD_OPTIONS}]"
if [[ "${PROJECT_TYPE}" == "MAVEN" ]]; then
if [[ "${CI}" == "CONCOURSE" ]]; then
./mvnw clean verify -Papicompatibility -Dlatest.production.version=${LATEST_PROD_VERSION} -Drepo.with.jars=${REPO_WITH_JARS} ${BUILD_OPTIONS} || ( $( printTestResults ) && return 1)
else
./mvnw clean verify -Papicompatibility -Dlatest.production.version=${LATEST_PROD_VERSION} -Drepo.with.jars=${REPO_WITH_JARS} ${BUILD_OPTIONS}
fi
elif [[ "${PROJECT_TYPE}" == "GRADLE" ]]; then
if [[ "${CI}" == "CONCOURSE" ]]; then
./gradlew clean apiCompatibility -DlatestProductionVersion=${LATEST_PROD_VERSION} -DREPO_WITH_JARS=${REPO_WITH_JARS} ${BUILD_OPTIONS} --stacktrace || ( $( printTestResults ) && return 1)
else
./gradlew clean apiCompatibility -DlatestProductionVersion=${LATEST_PROD_VERSION} -DREPO_WITH_JARS=${REPO_WITH_JARS} ${BUILD_OPTIONS} --stacktrace
fi
else
echo "Unsupported project build tool"
return 1
fi
fi
apiCompatibilityCheck
Loading

0 comments on commit 5cd5bf7

Please sign in to comment.