diff --git a/ci/config-concourse.yml b/ci/config-concourse.yml index 37206ad..b022459 100644 --- a/ci/config-concourse.yml +++ b/ci/config-concourse.yml @@ -1,8 +1,7 @@ +artifactory-server: https://repo.spring.io +build-name: spring-cloud-app-broker ab-slack-success-channel: "#sc-app-broker" ab-slack-failure-channel: "#sc-app-broker" -bintray-distribution-repo: spring-cloud-app-broker -bintray-package: spring-cloud-app-broker -bintray-repo: jars -bintray-subject: spring -build-name: spring-cloud-app-broker + + diff --git a/ci/config/release-scripts.yml b/ci/config/release-scripts.yml new file mode 100644 index 0000000..d31f8cb --- /dev/null +++ b/ci/config/release-scripts.yml @@ -0,0 +1,10 @@ +logging: + level: + io.spring.concourse: DEBUG +spring: + main: + banner-mode: off +sonatype: + exclude: + - 'build-info\.json' + - '.*\.zip' diff --git a/ci/images/app-broker-ci/Dockerfile b/ci/images/app-broker-ci/Dockerfile index a52282a..f480aea 100644 --- a/ci/images/app-broker-ci/Dockerfile +++ b/ci/images/app-broker-ci/Dockerfile @@ -12,15 +12,15 @@ ENV JAVA_HOME /opt/openjdk ENV PATH $JAVA_HOME/bin:$PATH RUN mkdir -p /opt/openjdk && \ cd /opt/openjdk && \ - curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u192-b12/OpenJDK8U-jdk_x64_linux_hotspot_8u192b12.tar.gz | tar xz --strip-components=2 + curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz | tar xz --strip-components=1 -ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.3/concourse-java.sh /opt/ -ADD https://repo.spring.io/libs-release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.2/concourse-release-scripts-0.3.2.jar /opt/ +ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh /opt/ +ADD https://repo.spring.io/libs-release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.3/concourse-release-scripts-0.3.3.jar /opt/ RUN cd /usr/local/bin && curl -L https://github.com/cloudfoundry-incubator/credhub-cli/releases/download/2.9.0/credhub-linux-2.9.0.tgz | tar xz -RUN curl -L https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.40/bbl-v8.4.40_linux_x86-64 --output /usr/local/bin/bbl && \ +RUN curl -L https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.43/bbl-v8.4.43_linux_x86-64 --output /usr/local/bin/bbl && \ chmod +x /usr/local/bin/bbl -RUN curl -L https://github.com/cloudfoundry/bosh-cli/releases/download/v6.4.3/bosh-cli-6.4.3-linux-amd64 --output /usr/local/bin/bosh && \ +RUN curl -L https://github.com/cloudfoundry/bosh-cli/releases/download/v6.4.4/bosh-cli-6.4.4-linux-amd64 --output /usr/local/bin/bosh && \ chmod +x /usr/local/bin/bosh diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 140c8f3..69ec423 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -44,12 +44,8 @@ jobs: build_uri: "${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}" build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}" disable_checksum_uploads: true - artifact_set: - - include: - - "/**/spring-cloud-app-broker-*-docs.zip" - properties: - "zip.type": "docs" - "zip.deployed": "false" + on_failure: + *slack-failure-notification - name: run-acceptance-tests serial: true @@ -81,7 +77,6 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml @@ -100,7 +95,6 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml @@ -119,7 +113,6 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml @@ -138,9 +131,7 @@ jobs: serial: true plan: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false passed: [stage-milestone] params: save_build_info: true @@ -155,9 +146,7 @@ jobs: plan: - in_parallel: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false passed: [stage-rc] params: save_build_info: true @@ -172,9 +161,7 @@ jobs: plan: - in_parallel: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false passed: [stage-release] params: save_build_info: true @@ -184,51 +171,26 @@ jobs: release-type: RELEASE ci-image-tag: ((ci-image-tag)) - - name: distribute-release - serial: true - plan: - - in_parallel: - - get: git-repo - trigger: false - - get: artifactory-repo - trigger: false - passed: [promote-release] - params: - save_build_info: true - - task: distribute - file: git-repo/ci/tasks/distribute.yml - vars: - ci-image-tag: ((ci-image-tag)) - bintray-distribution-repo: ((bintray-distribution-repo)) - bintray-package: ((bintray-package)) - bintray-repo: ((bintray-repo)) - bintray-subject: ((bintray-subject)) - - name: sync-to-maven-central serial: true plan: - in_parallel: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false - passed: [distribute-release] + passed: [promote-release] params: save_build_info: true - task: sync-to-maven-central file: git-repo/ci/tasks/sync-to-maven-central.yml vars: ci-image-tag: ((ci-image-tag)) - bintray-package: ((bintray-package)) - bintray-repo: ((bintray-repo)) - bintray-subject: ((bintray-subject)) resource_types: - name: artifactory-resource type: registry-image source: repository: ((dockerhub-mirror-registry))/springio/artifactory-resource - tag: 0.0.12 + tag: 0.0.14 - name: slack-notification type: registry-image @@ -313,7 +275,6 @@ groups: jobs: - stage-release - promote-release - - distribute-release - sync-to-maven-central - name: "ci-images" jobs: diff --git a/ci/scripts/distribute.sh b/ci/scripts/distribute.sh deleted file mode 100755 index 359a879..0000000 --- a/ci/scripts/distribute.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -set -e - -# shellcheck source=scripts/common.sh -source "$(dirname "$0")/common.sh" - -buildName=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.name') -buildNumber=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.number') -version=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/') - -echo "Distributing ${buildName}/${buildNumber} to ${BINTRAY_DISTRIBUTION_REPO}" - -curl \ - -s \ - --connect-timeout 240 \ - --max-time 2700 \ - -u "${ARTIFACTORY_USERNAME}":"${ARTIFACTORY_PASSWORD}" \ - -H "Content-type:application/json" \ - -d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"${BINTRAY_DISTRIBUTION_REPO}\", \"async\":\"true\"}" \ - -f \ - -X \ - POST "${ARTIFACTORY_SERVER}/api/build/distribute/${buildName}/${buildNumber}" >/dev/null || { - echo "Failed to promote" >&2 - exit 1 -} - -echo "Waiting for artifacts to be distributed" - -WAIT_TIME=20 -WAIT_ATTEMPTS=120 - -artifacts_published=false -retry_counter=0 -while [ $artifacts_published == "false" ] && [ $retry_counter -lt $WAIT_ATTEMPTS ]; do - result=$(curl -s -f -u "${BINTRAY_USERNAME}":"${BINTRAY_API_KEY}" https://api.bintray.com/packages/"${BINTRAY_SUBJECT}"/"${BINTRAY_REPO}"/"${BINTRAY_PACKAGE}") - if [ $? -eq 0 ]; then - versions=$(echo "$result" | jq -r '.versions') - exists=$(echo "$versions" | grep "$version" -o || true) - if [ "$exists" = "$version" ]; then - artifacts_published=true - fi - fi - retry_counter=$((retry_counter + 1)) - sleep $WAIT_TIME -done -if [[ $artifacts_published == "false" ]]; then - echo "Failed to distribute" - exit 1 -fi - -echo "Distribution complete" -echo $version >version/version diff --git a/ci/scripts/promote.sh b/ci/scripts/promote.sh index 4f6b65e..97e0e22 100755 --- a/ci/scripts/promote.sh +++ b/ci/scripts/promote.sh @@ -1,39 +1,13 @@ #!/bin/bash -set -e +set -euo pipefail # shellcheck source=scripts/common.sh -source "$(dirname "$0")/common.sh" +source $(dirname $0)/common.sh -buildName=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.name') -buildNumber=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.number') -version=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/') +version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) +export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json -if [[ $RELEASE_TYPE == "M" ]]; then - targetRepo="libs-milestone-local" -elif [[ $RELEASE_TYPE == "RC" ]]; then - targetRepo="libs-milestone-local" -elif [[ $RELEASE_TYPE == "RELEASE" ]]; then - targetRepo="libs-release-local" -else - echo "Unknown release type $RELEASE_TYPE" >&2 - exit 1 -fi - -echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}" - -curl \ - -s \ - --connect-timeout 240 \ - --max-time 900 \ - -u "${ARTIFACTORY_USERNAME}":"${ARTIFACTORY_PASSWORD}" \ - -H "Content-type:application/json" \ - -d "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"${targetRepo}\"}" \ - -f \ - -X \ - POST "${ARTIFACTORY_SERVER}/api/build/promote/${buildName}/${buildNumber}" >/dev/null || { - echo "Failed to promote" >&2 - exit 1 -} +java -jar /opt/concourse-release-scripts*.jar promote $RELEASE_TYPE $BUILD_INFO_LOCATION echo "Promotion complete" -echo $version >version/version +echo $version > version/version diff --git a/ci/scripts/sync-to-maven-central.sh b/ci/scripts/sync-to-maven-central.sh index 1acfbfa..ef5269f 100755 --- a/ci/scripts/sync-to-maven-central.sh +++ b/ci/scripts/sync-to-maven-central.sh @@ -1,21 +1,11 @@ #!/bin/bash -set -e +set -euo pipefail -buildName=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.name') -buildNumber=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.number') -version=$(cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/') +readonly BUILD_INFO_LOCATION="$(pwd)/artifactory-repo/build-info.json" +readonly CONFIG_DIR="$(pwd)/git-repo/ci/config" + +java -jar /opt/concourse-release-scripts*.jar \ + --spring.config.location="${CONFIG_DIR}/release-scripts.yml" \ + publishToCentral 'RELEASE' "$BUILD_INFO_LOCATION" "artifactory-repo" -echo "Syncing ${buildName}/${buildNumber} to Maven Central" -curl \ - -s \ - --connect-timeout 240 \ - --max-time 2700 \ - -u "${BINTRAY_USERNAME}":"${BINTRAY_API_KEY}" \ - -H "Content-Type: application/json" -d "{\"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \ - -f \ - -X \ - POST "https://api.bintray.com/maven_central_sync/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/versions/${version}" >/dev/null || { - echo "Failed to sync" >&2 - exit 1 -} echo "Sync complete" diff --git a/ci/tasks/acceptance-tests.yml b/ci/tasks/acceptance-tests.yml index bfe8a5d..ff1de99 100644 --- a/ci/tasks/acceptance-tests.yml +++ b/ci/tasks/acceptance-tests.yml @@ -4,6 +4,8 @@ image_resource: type: registry-image source: repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci + username: ((corporate-harbor-robot-account.username)) + password: ((corporate-harbor-robot-account.password)) tag: ((ci-image-tag)) inputs: - name: git-repo diff --git a/ci/tasks/build-project.yml b/ci/tasks/build-project.yml index 8507e99..b68058a 100644 --- a/ci/tasks/build-project.yml +++ b/ci/tasks/build-project.yml @@ -4,6 +4,8 @@ image_resource: type: registry-image source: repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci + username: ((corporate-harbor-robot-account.username)) + password: ((corporate-harbor-robot-account.password)) tag: ((ci-image-tag)) inputs: - name: git-repo @@ -15,5 +17,5 @@ caches: run: path: git-repo/ci/scripts/build-project.sh params: - ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true - SKIP_TESTS: false + ARTIFACTORY_USERNAME: ((artifactory-username)) + ARTIFACTORY_PASSWORD: ((artifactory-password)) diff --git a/ci/tasks/distribute.yml b/ci/tasks/distribute.yml deleted file mode 100644 index 9386df2..0000000 --- a/ci/tasks/distribute.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -platform: linux -image_resource: - type: registry-image - source: - repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci - tag: ((ci-image-tag)) -inputs: - - name: git-repo - - name: artifactory-repo -outputs: - - name: version -params: - ARTIFACTORY_SERVER: ((artifactory-server)) - ARTIFACTORY_USERNAME: ((artifactory-username)) - ARTIFACTORY_PASSWORD: ((artifactory-password)) - BINTRAY_SUBJECT: ((bintray-subject)) - BINTRAY_REPO: ((bintray-repo)) - BINTRAY_USERNAME: ((bintray-username)) - BINTRAY_API_KEY: ((bintray-api-key)) - BINTRAY_PACKAGE: ((bintray-package)) - BINTRAY_DISTRIBUTION_REPO: ((bintray-distribution-repo)) -run: - path: git-repo/ci/scripts/distribute.sh diff --git a/ci/tasks/promote.yml b/ci/tasks/promote.yml index 90a8f4d..4744e09 100644 --- a/ci/tasks/promote.yml +++ b/ci/tasks/promote.yml @@ -4,6 +4,8 @@ image_resource: type: registry-image source: repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci + username: ((corporate-harbor-robot-account.username)) + password: ((corporate-harbor-robot-account.password)) tag: ((ci-image-tag)) inputs: - name: git-repo diff --git a/ci/tasks/stage.yml b/ci/tasks/stage.yml index 1db0803..e9a3b8b 100644 --- a/ci/tasks/stage.yml +++ b/ci/tasks/stage.yml @@ -4,6 +4,8 @@ image_resource: type: registry-image source: repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci + username: ((corporate-harbor-robot-account.username)) + password: ((corporate-harbor-robot-account.password)) tag: ((ci-image-tag)) inputs: - name: git-repo diff --git a/ci/tasks/sync-to-maven-central.yml b/ci/tasks/sync-to-maven-central.yml index 98edc75..0a8bad6 100644 --- a/ci/tasks/sync-to-maven-central.yml +++ b/ci/tasks/sync-to-maven-central.yml @@ -4,17 +4,16 @@ image_resource: type: registry-image source: repository: ((corporate-harbor-registry))/((dockerhub-organization))/app-broker-ci + username: ((corporate-harbor-robot-account.username)) + password: ((corporate-harbor-robot-account.password)) tag: ((ci-image-tag)) inputs: - name: git-repo - name: artifactory-repo params: - BINTRAY_REPO: ((bintray-repo)) - BINTRAY_SUBJECT: ((bintray-subject)) - BINTRAY_USERNAME: ((bintray-username)) - BINTRAY_API_KEY: ((bintray-api-key)) - BINTRAY_PACKAGE: ((bintray-package)) - SONATYPE_USER_TOKEN: ((sonatype-user-token)) - SONATYPE_PASSWORD_TOKEN: ((sonatype-password-token)) + SONATYPE_URL: ((sonatype-url)) + SONATYPE_USERNAME: ((sonatype-user-token)) + SONATYPE_PASSWORD: ((sonatype-user-token-password)) + SONATYPE_STAGING_PROFILE_ID: ((sonatype-staging-profile-id)) run: path: git-repo/ci/scripts/sync-to-maven-central.sh diff --git a/scripts/set-pipelines.sh b/scripts/set-pipelines.sh index 1d2d816..debc5ac 100755 --- a/scripts/set-pipelines.sh +++ b/scripts/set-pipelines.sh @@ -2,6 +2,9 @@ set -euo pipefail +readonly FLY_TARGET="app-broker" +readonly GITHUB_REPO="https://github.com/spring-cloud/spring-cloud-app-broker" + set_pipeline() { local pipeline_name pipeline_definition branch ci_image_tag pipeline_name="${1:?pipeline name must be provided}" @@ -10,10 +13,11 @@ set_pipeline() { ci_image_tag="${4:-$branch}" echo "Setting $pipeline_name pipeline..." - fly --target app-broker set-pipeline \ + fly --target "$FLY_TARGET" set-pipeline \ --pipeline "$pipeline_name" \ --config "$pipeline_definition" \ --load-vars-from config-concourse.yml \ + --var "github-repo=$GITHUB_REPO" \ --var "branch=$branch" \ --var "ci-image-tag=$ci_image_tag" }