From 2b8f2d31f9356aee902b7ca03298dc85f016f172 Mon Sep 17 00:00:00 2001 From: Gareth Clay Date: Wed, 1 Sep 2021 17:18:17 +0100 Subject: [PATCH] Update to latest pipeline definitions --- ci/config-concourse.yml | 9 +- ci/config/release-scripts.yml | 10 ++ ci/images/app-broker-ci/Dockerfile | 26 +++++ ci/images/release-ci-image/Dockerfile | 13 --- ci/pipeline.yml | 154 +++++++++++++------------- ci/pr-pipeline.yml | 48 ++++++-- ci/scripts/acceptance-tests.sh | 72 ++++++++++-- ci/scripts/distribute.sh | 52 --------- ci/scripts/promote.sh | 38 +------ ci/scripts/stage.sh | 5 +- ci/scripts/sync-to-maven-central.sh | 24 ++-- ci/tasks/acceptance-tests.yml | 16 ++- ci/tasks/build-project.yml | 10 +- ci/tasks/distribute.yml | 24 ---- ci/tasks/promote.yml | 6 +- ci/tasks/stage.yml | 8 +- ci/tasks/sync-to-maven-central.yml | 17 ++- scripts/set-pipelines.sh | 12 +- 18 files changed, 267 insertions(+), 277 deletions(-) create mode 100644 ci/config/release-scripts.yml create mode 100644 ci/images/app-broker-ci/Dockerfile delete mode 100644 ci/images/release-ci-image/Dockerfile delete mode 100755 ci/scripts/distribute.sh delete mode 100644 ci/tasks/distribute.yml 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 new file mode 100644 index 0000000..f480aea --- /dev/null +++ b/ci/images/app-broker-ci/Dockerfile @@ -0,0 +1,26 @@ +FROM harbor-repo.vmware.com/dockerhub-proxy-cache/library/ubuntu:bionic + +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates net-tools git curl jq gnupg + +RUN curl -L https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | apt-key add - +RUN echo "deb https://packages.cloudfoundry.org/debian stable main" | tee /etc/apt/sources.list.d/cloudfoundry-cli.list +RUN apt-get update && apt-get install cf-cli + +RUN rm -rf /var/lib/apt/lists/* + +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/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.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.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.4/bosh-cli-6.4.4-linux-amd64 --output /usr/local/bin/bosh && \ + chmod +x /usr/local/bin/bosh diff --git a/ci/images/release-ci-image/Dockerfile b/ci/images/release-ci-image/Dockerfile deleted file mode 100644 index d6edd90..0000000 --- a/ci/images/release-ci-image/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:bionic-20181018 - -RUN apt-get update -RUN apt-get install --no-install-recommends -y ca-certificates net-tools git curl jq -RUN rm -rf /var/lib/apt/lists/* - -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 - -ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.2/concourse-java.sh /opt/ diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 59a1f1f..69ec423 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -6,23 +6,25 @@ aliases: icon_emoji: ":concourse:" username: concourse channel: ((ab-slack-success-channel)) - text: "$BUILD_PIPELINE_NAME pipeline has succeeded with build !" + text: "$BUILD_PIPELINE_NAME pipeline has succeeded with build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME>!" - &slack-failure-notification put: alert params: icon_emoji: ":animal-1252:" username: concourse channel: ((ab-slack-failure-channel)) - text: Build of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed! + text: Build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed! jobs: - - name: build-release-ci-images + - name: build-ci-images plan: - get: ci-images-git-repo trigger: true - - put: release-ci-image + - put: app-broker-ci-image params: - build: ci-images-git-repo/ci/images/release-ci-image + build: ci-images-git-repo/ci/images/app-broker-ci + get_params: + skip_download: "true" - name: build serial: true @@ -34,32 +36,40 @@ jobs: timeout: 1h30m file: git-repo/ci/tasks/build-project.yml vars: - docker-hub-organization: ((docker-hub-organization)) - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - put: artifactory-repo params: &artifactory-params repo: libs-snapshot-local folder: distribution-repository - build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}" + 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 plan: - - get: git-repo - passed: [build] - trigger: true + - in_parallel: + - get: git-repo + passed: [build] + trigger: true + - put: toolsmith-env + inputs: [] + params: + action: claim - task: acceptance-tests file: git-repo/ci/tasks/acceptance-tests.yml + vars: + ci-image-tag: ((ci-image-tag)) on_success: - *slack-success-notification + in_parallel: + - *slack-success-notification + - put: toolsmith-env + params: + action: unclaim + env_file: toolsmith-env/metadata + inputs: [toolsmith-env] on_failure: *slack-failure-notification @@ -67,13 +77,12 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml vars: release-type: M - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - put: artifactory-repo params: <<: *artifactory-params @@ -86,13 +95,12 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml vars: release-type: RC - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - put: artifactory-repo params: <<: *artifactory-params @@ -105,13 +113,12 @@ jobs: serial: true plan: - get: git-repo - trigger: false passed: [run-acceptance-tests] - task: stage file: git-repo/ci/tasks/stage.yml vars: release-type: RELEASE - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - put: artifactory-repo params: <<: *artifactory-params @@ -124,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 @@ -134,16 +139,14 @@ jobs: file: git-repo/ci/tasks/promote.yml vars: release-type: M - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - name: promote-rc serial: true plan: - in_parallel: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false passed: [stage-rc] params: save_build_info: true @@ -151,16 +154,14 @@ jobs: file: git-repo/ci/tasks/promote.yml vars: release-type: RC - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - name: promote-release serial: true plan: - in_parallel: - get: git-repo - trigger: false - get: artifactory-repo - trigger: false passed: [stage-release] params: save_build_info: true @@ -168,53 +169,40 @@ jobs: file: git-repo/ci/tasks/promote.yml vars: release-type: RELEASE - release-image-tag: ((release-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: - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - 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: - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) resource_types: - name: artifactory-resource - type: docker-image + type: registry-image source: - repository: springio/artifactory-resource - tag: 0.0.12 + repository: ((dockerhub-mirror-registry))/springio/artifactory-resource + tag: 0.0.14 - name: slack-notification - type: docker-image + type: registry-image source: - repository: cfcommunity/slack-notification-resource + repository: ((dockerhub-mirror-registry))/cfcommunity/slack-notification-resource tag: latest + - name: pcf-pool + type: registry-image + source: + repository: ((dockerhub-mirror-registry))/cftoolsmiths/toolsmiths-envs-resource + resources: - name: git-repo type: git @@ -233,11 +221,6 @@ resources: username: ((github-username)) password: ((github-password)) branch: ((github-username))/staging - git_config: - - name: user.name - value: ((git-username)) - - name: user.email - value: ((git-email)) - name: ci-images-git-repo type: git @@ -246,13 +229,13 @@ resources: branch: ((branch)) paths: ["ci/images/*"] - - name: release-ci-image + - name: app-broker-ci-image type: docker-image source: - repository: ((docker-hub-organization))/release-ci-image - username: ((docker-hub-username)) - password: ((docker-hub-password)) - tag: ((release-image-tag)) + 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)) - name: artifactory-repo type: artifactory-resource @@ -267,19 +250,32 @@ resources: source: url: ((scs-slack-webhook)) + - name: toolsmith-env + type: pcf-pool + icon: pool + source: + api_token: ((toolsmith-api-token)) + hostname: environments.toolsmiths.cf-app.com + pool_name: cf-deployment + groups: - - name: "Main" + - name: "build" jobs: - build - run-acceptance-tests - - stage-milestone - - stage-rc - - stage-release - - promote-milestone - - promote-rc - - promote-release - - distribute-release - - sync-to-maven-central - - name: "CI Images" + - name: "milestone" jobs: - - build-release-ci-images + - stage-milestone + - promote-milestone + - name: "rc" + jobs: + - stage-rc + - promote-rc + - name: "release" + jobs: + - stage-release + - promote-release + - sync-to-maven-central + - name: "ci-images" + jobs: + - build-ci-images diff --git a/ci/pr-pipeline.yml b/ci/pr-pipeline.yml index f6472a4..5a7090f 100644 --- a/ci/pr-pipeline.yml +++ b/ci/pr-pipeline.yml @@ -6,14 +6,14 @@ aliases: icon_emoji: ":concourse:" username: concourse channel: ((ab-slack-success-channel)) - text: "$BUILD_PIPELINE_NAME pipeline has succeeded with build !" + text: "$BUILD_PIPELINE_NAME pipeline has succeeded with build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME>!" - &slack-failure-notification put: alert params: icon_emoji: ":animal-1252:" username: concourse channel: ((ab-slack-failure-channel)) - text: Build of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed! + text: Build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed! jobs: - name: build @@ -27,36 +27,53 @@ jobs: input_mapping: git-repo: pull-request vars: - docker-hub-organization: ((docker-hub-organization)) - release-image-tag: ((release-image-tag)) + ci-image-tag: ((ci-image-tag)) - name: run-acceptance-tests serial: true plan: - - get: pull-request - passed: [build] - trigger: true + - in_parallel: + - get: pull-request + passed: [build] + trigger: true + - put: toolsmith-env + inputs: [ ] + params: + action: claim - task: acceptance-tests file: pull-request/ci/tasks/acceptance-tests.yml input_mapping: git-repo: pull-request + vars: + ci-image-tag: ((ci-image-tag)) on_success: - *slack-success-notification + in_parallel: + - *slack-success-notification + - put: toolsmith-env + params: + action: unclaim + env_file: toolsmith-env/metadata + inputs: [ toolsmith-env ] on_failure: *slack-failure-notification resource_types: - name: pull-request - type: docker-image + type: registry-image source: - repository: teliaoss/github-pr-resource + repository: ((dockerhub-mirror-registry))/teliaoss/github-pr-resource - name: slack-notification - type: docker-image + type: registry-image source: - repository: cfcommunity/slack-notification-resource + repository: ((dockerhub-mirror-registry))/cfcommunity/slack-notification-resource tag: latest + - name: pcf-pool + type: registry-image + source: + repository: ((dockerhub-mirror-registry))/cftoolsmiths/toolsmiths-envs-resource + resources: - name: pull-request type: pull-request @@ -71,3 +88,10 @@ resources: source: url: ((scs-slack-webhook)) + - name: toolsmith-env + type: pcf-pool + icon: pool + source: + api_token: ((toolsmith-api-token)) + hostname: environments.toolsmiths.cf-app.com + pool_name: cf-deployment diff --git a/ci/scripts/acceptance-tests.sh b/ci/scripts/acceptance-tests.sh index 78fb973..b17e51e 100755 --- a/ci/scripts/acceptance-tests.sh +++ b/ci/scripts/acceptance-tests.sh @@ -2,16 +2,59 @@ set -euo pipefail -readonly API_HOST="${API_HOST:?must be set}" -readonly API_PORT="${API_PORT:?must be set}" -readonly USERNAME="${USERNAME:?must be set}" -readonly PASSWORD="${PASSWORD:?must be set}" -readonly CLIENT_ID="${CLIENT_ID:?must be set}" -readonly CLIENT_SECRET="${CLIENT_SECRET:?must be set}" +readonly TOOLSMITH_ENV_INPUT="${TOOLSMITH_ENV_INPUT:?must be set}" readonly DEFAULT_ORG="${DEFAULT_ORG:?must be set}" readonly DEFAULT_SPACE="${DEFAULT_SPACE:?must be set}" readonly SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION:?must be set}" readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:-true}" +readonly DEPLOYMENT_DIRECTORY="$(mktemp -d)" + +declare API_HOST +readonly API_PORT=443 +readonly USERNAME="admin" +declare PASSWORD +readonly CLIENT_ID="admin" +declare CLIENT_SECRET + +discover_environment() { + local env_name + env_name=$(cat "$TOOLSMITH_ENV_INPUT/name") + + eval "$(bbl print-env --metadata-file "$TOOLSMITH_ENV_INPUT/metadata")" + + API_HOST="$(jq -r .cf.api_url <"$TOOLSMITH_ENV_INPUT/metadata")" + PASSWORD="$(credhub get -n "/bosh-${env_name}/cf/cf_admin_password" -q)" + CLIENT_SECRET="$(credhub get -n "/bosh-${env_name}/cf/uaa_admin_client_secret" -q)" +} + +prepare_cf_deployment() { + pushd "$DEPLOYMENT_DIRECTORY" > /dev/null + + bosh --deployment cf manifest > manifest.yml + + cat << EOF > ops.yml +- type: replace + path: /instance_groups/name=diego-cell/instances + value: 3 +EOF + + bosh --non-interactive --deployment cf deploy --ops-file ops.yml manifest.yml + + popd > /dev/null +} + +prepare_cf() { + local test_instances_org + test_instances_org="$DEFAULT_ORG-instances" + + cf login -a "$API_HOST" -u "$USERNAME" -p "$PASSWORD" -o system --skip-ssl-validation "$SKIP_SSL_VALIDATION" + + cf create-org "$DEFAULT_ORG" + cf create-space "$DEFAULT_SPACE" -o "$DEFAULT_ORG" + + cf create-org "$test_instances_org" + cf create-space "$DEFAULT_SPACE" -o "$test_instances_org" +} run_tests() { export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${API_HOST}" @@ -24,18 +67,23 @@ run_tests() { export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}" export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}" export TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar - ./gradlew -PacceptanceTests \ - -PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \ - :spring-cloud-app-broker-acceptance-tests:test + ./gradlew --console rich -PacceptanceTests \ + -PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \ + :spring-cloud-app-broker-acceptance-tests:test } main() { + discover_environment + echo "Running tests against $API_HOST" echo - pushd "git-repo" > /dev/null - run_tests - popd > /dev/null + prepare_cf_deployment + prepare_cf + + pushd "git-repo" >/dev/null + run_tests + popd >/dev/null } main 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/stage.sh b/ci/scripts/stage.sh index 801de82..68b6e7e 100755 --- a/ci/scripts/stage.sh +++ b/ci/scripts/stage.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -euo pipefail +set -eo pipefail # shellcheck source=scripts/common.sh source "$(dirname "$0")/common.sh" @@ -10,6 +10,9 @@ echo pushd stage-git-repo >/dev/null +git config user.name $USER_NAME +git config user.email $USER_EMAIL + snapshotVersion=$(awk -F '=' '$1 == "version" { print $2 }' gradle.properties) if [[ $RELEASE_TYPE == "M" ]]; then stageVersion=$(get_next_milestone_release "$snapshotVersion") 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 f162cd0..ff1de99 100644 --- a/ci/tasks/acceptance-tests.yml +++ b/ci/tasks/acceptance-tests.yml @@ -1,21 +1,19 @@ --- platform: linux image_resource: - type: docker-image + type: registry-image source: - repository: openjdk - tag: 8 + 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: toolsmith-env run: path: git-repo/ci/scripts/acceptance-tests.sh params: - API_HOST: ((acceptance-test-api-host)) - API_PORT: ((acceptance-test-api-port)) - USERNAME: ((acceptance-test-username)) - PASSWORD: ((acceptance-test-password)) - CLIENT_ID: ((acceptance-test-client-id)) - CLIENT_SECRET: ((acceptance-test-client-secret)) + TOOLSMITH_ENV_INPUT: toolsmith-env DEFAULT_ORG: ((acceptance-test-default-org)) DEFAULT_SPACE: ((acceptance-test-default-space)) SKIP_SSL_VALIDATION: ((acceptance-test-skip-ssl-validation)) diff --git a/ci/tasks/build-project.yml b/ci/tasks/build-project.yml index 7ac086f..b68058a 100644 --- a/ci/tasks/build-project.yml +++ b/ci/tasks/build-project.yml @@ -3,8 +3,10 @@ platform: linux image_resource: type: registry-image source: - repository: ((docker-hub-organization))/release-ci-image - tag: ((release-image-tag)) + 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 outputs: @@ -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 b6ee867..0000000 --- a/ci/tasks/distribute.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -platform: linux -image_resource: - type: registry-image - source: - repository: ((docker-hub-organization))/release-ci-image - tag: ((release-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 bb1c784..4744e09 100644 --- a/ci/tasks/promote.yml +++ b/ci/tasks/promote.yml @@ -3,8 +3,10 @@ platform: linux image_resource: type: registry-image source: - repository: ((docker-hub-organization))/release-ci-image - tag: ((release-image-tag)) + 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 diff --git a/ci/tasks/stage.yml b/ci/tasks/stage.yml index 4bc3b1f..e9a3b8b 100644 --- a/ci/tasks/stage.yml +++ b/ci/tasks/stage.yml @@ -3,8 +3,10 @@ platform: linux image_resource: type: registry-image source: - repository: ((docker-hub-organization))/release-ci-image - tag: ((release-image-tag)) + 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 outputs: @@ -12,6 +14,8 @@ outputs: - name: distribution-repository params: RELEASE_TYPE: ((release-type)) + USER_NAME: ((git-username)) + USER_EMAIL: ((git-email)) caches: - path: maven - path: gradle diff --git a/ci/tasks/sync-to-maven-central.yml b/ci/tasks/sync-to-maven-central.yml index 28741e4..0a8bad6 100644 --- a/ci/tasks/sync-to-maven-central.yml +++ b/ci/tasks/sync-to-maven-central.yml @@ -3,18 +3,17 @@ platform: linux image_resource: type: registry-image source: - repository: ((docker-hub-organization))/release-ci-image - tag: ((release-image-tag)) + 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 516168d..8c57573 100755 --- a/scripts/set-pipelines.sh +++ b/scripts/set-pipelines.sh @@ -2,20 +2,24 @@ 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 release_image_tag + local pipeline_name pipeline_definition branch ci_image_tag pipeline_name="${1:?pipeline name must be provided}" pipeline_definition="${2:?pipeline definition file must be provided}" branch="${3:?branch must be provided}" - release_image_tag="${4:-$branch}" + 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 "release-image-tag=$release_image_tag" + --var "ci-image-tag=$ci_image_tag" } main() {