diff --git a/ci/README.md b/ci/README.md index 93879f4..2d02a55 100644 --- a/ci/README.md +++ b/ci/README.md @@ -1,4 +1,4 @@ -#App Broker CI Pipeline +# App Broker CI Pipeline ## Running the acceptance tests on Cloud Foundry locally @@ -36,7 +36,7 @@ The original pipeline was decomposed into different jobs so that we could recove ### Fly -The pipeline can be run using the following script: +The pipeline can be run using the following script from the `main` branch: ```$bash $ ./ci/scripts/set-pipeline.sh diff --git a/ci/config-concourse.yml b/ci/config-concourse.yml deleted file mode 100644 index 7e81e19..0000000 --- a/ci/config-concourse.yml +++ /dev/null @@ -1,5 +0,0 @@ -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" -github-repo: https://github.com/spring-cloud/spring-cloud-app-broker diff --git a/ci/images/app-broker-ci/Dockerfile b/ci/images/app-broker-ci/Dockerfile index f9fd98f..8993804 100644 --- a/ci/images/app-broker-ci/Dockerfile +++ b/ci/images/app-broker-ci/Dockerfile @@ -31,7 +31,6 @@ RUN apt-get update && \ apt-get clean ADD "https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v$CONCOURSE_JAVA_SCRIPTS_VERSION/concourse-java.sh" /opt/ -ADD "https://repo.spring.io/ui/native/snapshot/io/spring/concourse/releasescripts/concourse-release-scripts/$CONCOURSE_RELEASE_SCRIPTS_VERSION/concourse-release-scripts-$CONCOURSE_RELEASE_SCRIPTS_VERSION.jar" /opt/ RUN cd /usr/local/bin && curl -L "https://github.com/cloudfoundry-incubator/credhub-cli/releases/download/$CREDHUB_CLI_VERSION/credhub-linux-$CREDHUB_CLI_VERSION.tgz" | tar xz diff --git a/ci/pipeline.yml b/ci/pipeline.yml deleted file mode 100644 index ca4cbf5..0000000 --- a/ci/pipeline.yml +++ /dev/null @@ -1,342 +0,0 @@ ---- -aliases: - - &slack-success-notification - put: alert - params: - icon_emoji: ":concourse:" - username: concourse - channel: ((ab-slack-success-channel)) - text: "`$BUILD_PIPELINE_NAME ((branch))` 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 <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job `$BUILD_JOB_NAME` in the `$BUILD_PIPELINE_NAME ((branch))` pipeline has failed!" - -jobs: - - name: build-ci-images - plan: - - get: ci-images-git-repo - trigger: true - - task: build-image - privileged: true - tags: [ btrfs ] - config: - platform: linux - image_resource: - type: registry-image - source: - repository: ((dockerhub-mirror-registry))/concourse/oci-build-task - tag: 0.10.0 - inputs: - - name: source - outputs: - - name: image - run: - path: build - input_mapping: - source: ci-images-git-repo - params: - CONTEXT: source/ci/images/app-broker-ci - - put: app-broker-ci-image - inputs: detect - params: - image: image/image.tar - get_params: - skip_download: true - on_failure: *slack-failure-notification - - - name: build - serial: true - public: true - plan: - - get: nightly - trigger: true - - get: git-repo - trigger: true - - task: build-project - timeout: 1h30m - file: git-repo/ci/tasks/build-project.yml - vars: - ci-image-tag: ((ci-image-tag)) - - put: artifactory-repo - params: &artifactory-params - signing_key: ((signing-key)) - signing_passphrase: ((signing-passphrase)) - repo: libs-snapshot-local - folder: distribution-repository - 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 - on_failure: - *slack-failure-notification - on_error: - *slack-failure-notification - - - name: run-acceptance-tests - serial: true - plan: - - in_parallel: - - get: nightly - passed: [build] - trigger: true - - 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: - in_parallel: - - *slack-success-notification - - put: toolsmith-env - params: - action: unclaim - env_file: toolsmith-env/metadata - inputs: [toolsmith-env] - on_failure: - *slack-failure-notification - on_error: - *slack-failure-notification - - - name: stage-milestone - serial: true - plan: - - get: git-repo - passed: [run-acceptance-tests] - - task: stage - file: git-repo/ci/tasks/stage.yml - vars: - release-type: M - ci-image-tag: ((ci-image-tag)) - - put: artifactory-repo - params: - <<: *artifactory-params - repo: libs-staging-local - - put: git-repo-staging - params: - repository: stage-git-repo - - - name: stage-rc - serial: true - plan: - - get: git-repo - passed: [run-acceptance-tests] - - task: stage - file: git-repo/ci/tasks/stage.yml - vars: - release-type: RC - ci-image-tag: ((ci-image-tag)) - - put: artifactory-repo - params: - <<: *artifactory-params - repo: libs-staging-local - - put: git-repo-staging - params: - repository: stage-git-repo - - - name: stage-release - serial: true - plan: - - get: git-repo - passed: [run-acceptance-tests] - - task: stage - file: git-repo/ci/tasks/stage.yml - vars: - release-type: RELEASE - ci-image-tag: ((ci-image-tag)) - - put: artifactory-repo - params: - <<: *artifactory-params - repo: libs-staging-local - - put: git-repo-staging - params: - repository: stage-git-repo - - - name: promote-milestone - serial: true - plan: - - get: git-repo - - get: artifactory-repo - passed: [stage-milestone] - params: - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - vars: - release-type: M - ci-image-tag: ((ci-image-tag)) - - - name: promote-rc - serial: true - plan: - - in_parallel: - - get: git-repo - - get: artifactory-repo - passed: [stage-rc] - params: - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - vars: - release-type: RC - ci-image-tag: ((ci-image-tag)) - - - name: promote-release - serial: true - plan: - - in_parallel: - - get: git-repo - - get: artifactory-repo - passed: [stage-release] - params: - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - vars: - release-type: RELEASE - ci-image-tag: ((ci-image-tag)) - - - name: sync-to-maven-central - serial: true - plan: - - in_parallel: - - get: git-repo - - get: artifactory-repo - 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)) - -resource_types: - - name: artifactory-resource - type: registry-image - source: - repository: ((dockerhub-mirror-registry))/springio/artifactory-resource - tag: 0.0.14 - - - name: slack-notification - type: registry-image - source: - 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 - tag: latest - -resources: - - name: nightly - type: time - icon: calendar-clock - source: - start: 12:00 AM - stop: 1:00 AM - days: - - Monday - - Tuesday - - Wednesday - - Thursday - - Friday - location: America/New_York - initial_version: true - - - name: git-repo - type: git - source: - uri: ((github-repo)) - username: ((github-token)) - password: ((github-password)) - branch: ((branch)) - ignore_paths: ["ci/images/*"] - fetch_tags: true - - - name: git-repo-staging - type: git - source: - uri: ((github-repo)) - username: ((github-token)) - password: ((github-password)) - branch: ((github-username))/staging - - - name: ci-images-git-repo - type: git - source: - uri: ((github-repo)) - branch: ((branch)) - paths: ["ci/images/*"] - - - name: app-broker-ci-image - 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)) - - - name: artifactory-repo - type: artifactory-resource - source: - uri: ((artifactory-server)) - username: ((artifactory-username)) - password: ((artifactory-password)) - build_name: ((build-name)) - - - name: alert - type: slack-notification - 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: "build" - jobs: - - build - - run-acceptance-tests - - name: "milestone" - jobs: - - 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 - - name: "all" - jobs: - - build - - run-acceptance-tests - - stage-milestone - - promote-milestone - - stage-rc - - promote-rc - - stage-release - - promote-release - - sync-to-maven-central - - build-ci-images diff --git a/ci/pr-manager-pipeline.yml b/ci/pr-manager-pipeline.yml deleted file mode 100644 index b9f3504..0000000 --- a/ci/pr-manager-pipeline.yml +++ /dev/null @@ -1,64 +0,0 @@ -jobs: - - name: manage-pr-pipelines - plan: - - in_parallel: - - get: pipeline-definition - trigger: true - - get: pr - trigger: true - version: every - - task: list-prs - file: pipeline-definition/ci/tasks/list-prs.yml - input_mapping: - git-repo: pipeline-definition - vars: - ci-image-tag: ((ci-image-tag)) - - load_var: prs - file: prs/prs.json - - across: - - var: pr - values: ((.:prs)) - max_in_flight: all - in_parallel: - - set_pipeline: ((pipeline-name)) - file: pipeline-definition/ci/pr-pipeline.yml - var_files: - - pipeline-definition/ci/config-concourse.yml - vars: - ci-image-tag: ((.:pr.baseRefName)) - pr: - number: ((.:pr.number)) - commit: ((.:pr.headRefOid)) - base-branch: ((.:pr.baseRefName)) - instance_vars: - pr: ((.:pr.number)) - branch: ((.:pr.baseRefName)) - author: ((.:pr.author.login)) - -resource_types: - - name: pull-request - type: registry-image - source: - repository: ((dockerhub-mirror-registry))/teliaoss/github-pr-resource - tag: v0.23.0 - -resources: - - name: pipeline-definition - type: git - icon: github - source: - uri: ((github-repo)) - username: ((github-token)) - password: ((github-password)) - branch: main - paths: - - ci/pr-pipeline.yml - - ci/config-concourse.yml - - - name: pr - type: pull-request - icon: github - source: - repository: ((app-broker-pr-github-pull-requests-repo)) - access_token: ((app-broker-pr-github-pull-requests-access-token)) - required_review_approvals: 1 diff --git a/ci/pr-pipeline.yml b/ci/pr-pipeline.yml deleted file mode 100644 index bc3c603..0000000 --- a/ci/pr-pipeline.yml +++ /dev/null @@ -1,103 +0,0 @@ ---- -aliases: - - &slack-success-notification - put: alert - params: - icon_emoji: ":concourse:" - username: concourse - channel: ((ab-slack-success-channel)) - 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 <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job `$BUILD_JOB_NAME` in the `$BUILD_PIPELINE_NAME` pipeline has failed!" - -jobs: - - name: build - plan: - - get: pull-request - trigger: true - version: every - - task: build-project - timeout: 1h30m - file: pull-request/ci/tasks/build-project.yml - input_mapping: - git-repo: pull-request - vars: - ci-image-tag: ((ci-image-tag)) - - - name: run-acceptance-tests - serial: true - plan: - - 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 - vars: - ci-image-tag: ((ci-image-tag)) - input_mapping: - git-repo: pull-request - on_success: - in_parallel: - - *slack-success-notification - - put: toolsmith-env - params: - action: unclaim - env_file: toolsmith-env/metadata - inputs: [ toolsmith-env ] - on_failure: *slack-failure-notification - on_error: *slack-failure-notification - -resource_types: - - name: pull-request - type: registry-image - source: - repository: ((dockerhub-mirror-registry))/teliaoss/github-pr-resource - tag: latest - - - name: slack-notification - type: registry-image - source: - 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 - tag: latest - -resources: - - name: pull-request - type: pull-request - version: - pr: ((pr.number)) - commit: ((pr.commit)) - source: - repository: ((app-broker-pr-github-pull-requests-repo)) - access_token: ((app-broker-pr-github-pull-requests-access-token)) - base_branch: ((pr.base-branch)) - required_review_approvals: 1 - - - name: alert - type: slack-notification - 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/promote.sh b/ci/scripts/promote.sh index 97e0e22..54388d0 100755 --- a/ci/scripts/promote.sh +++ b/ci/scripts/promote.sh @@ -1,13 +1,10 @@ #!/bin/bash set -euo pipefail -# shellcheck source=scripts/common.sh -source $(dirname $0)/common.sh +readonly BUILD_INFO_LOCATION="$(pwd)/artifactory-repo/build-info.json" +readonly VERSION=$( jq -r '.buildInfo.modules[0].id' < "$BUILD_INFO_LOCATION" | 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 - -java -jar /opt/concourse-release-scripts*.jar promote $RELEASE_TYPE $BUILD_INFO_LOCATION +java -jar /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 ef5269f..10e1439 100755 --- a/ci/scripts/sync-to-maven-central.sh +++ b/ci/scripts/sync-to-maven-central.sh @@ -4,8 +4,8 @@ set -euo pipefail 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" \ +java -jar /concourse-release-scripts.jar \ + --spring.config.location="$CONFIG_DIR/release-scripts.yml" \ publishToCentral 'RELEASE' "$BUILD_INFO_LOCATION" "artifactory-repo" echo "Sync complete" diff --git a/ci/tasks/promote.yml b/ci/tasks/promote.yml index 4744e09..ef4a016 100644 --- a/ci/tasks/promote.yml +++ b/ci/tasks/promote.yml @@ -3,10 +3,8 @@ platform: linux 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)) + repository: ((dockerhub-mirror-registry))/springio/concourse-release-scripts + tag: '0.3.4' inputs: - name: git-repo - name: artifactory-repo diff --git a/ci/tasks/sync-to-maven-central.yml b/ci/tasks/sync-to-maven-central.yml index 0a8bad6..0b5d009 100644 --- a/ci/tasks/sync-to-maven-central.yml +++ b/ci/tasks/sync-to-maven-central.yml @@ -3,10 +3,8 @@ platform: linux 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)) + repository: ((dockerhub-mirror-registry))/springio/concourse-release-scripts + tag: '0.3.4' inputs: - name: git-repo - name: artifactory-repo diff --git a/scripts/set-pipelines.sh b/scripts/set-pipelines.sh deleted file mode 100755 index b6a4ce3..0000000 --- a/scripts/set-pipelines.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -readonly FLY_TARGET="app-broker" -readonly PIPELINE_NAME_SUFFIX="${PIPELINE_NAME_SUFFIX:-""}" -readonly PIPELINE_TYPE=${1:-""} - -[[ "$PIPELINE_NAME_SUFFIX" ]] && DISABLE_SLACK_ALERTING="true" || DISABLE_SLACK_ALERTING="false" - -set_branch_pipeline() { - local -r pipeline_name="app-broker${PIPELINE_NAME_SUFFIX:+"-$PIPELINE_NAME_SUFFIX"}" - local -r branches=("main" "1.6.x" "1.5.x" "1.4.x") - - for branch in "${branches[@]}"; do - echo "Setting $pipeline_name $branch pipeline..." - - fly --target "$FLY_TARGET" set-pipeline \ - --pipeline "$pipeline_name" \ - --config pipeline.yml \ - --load-vars-from config-concourse.yml \ - --instance-var "branch=$branch" \ - --var "ci-image-tag=$branch" \ - --var "disable-slack-alerting=$DISABLE_SLACK_ALERTING" \` - done -} - -set_pr_manager_pipeline() { - local -r pipeline_name="app-broker-pull-requests${PIPELINE_NAME_SUFFIX:+"-$PIPELINE_NAME_SUFFIX"}" - - echo "Setting PR manager pipeline..." - - fly --target "$FLY_TARGET" set-pipeline --pipeline "$pipeline_name" \ - --config pr-manager-pipeline.yml \ - --load-vars-from config-concourse.yml \ - --var ci-image-tag="main" \ - --var pipeline-name="$pipeline_name" -} - -set_pr_pipeline() { - local -r pr_number="${1:?first argument must be the PR number}" - local -r pipeline_name="app-broker-pr-$pr_number${PIPELINE_NAME_SUFFIX:+"-$PIPELINE_NAME_SUFFIX"}" - - echo "Setting PR pipeline for PR $pr_number..." - - local -r pr_info="$(gh pr view "$pr_number" --json baseRefName,headRefOid)" - - fly --target "$FLY_TARGET" set-pipeline --pipeline "$pipeline_name" \ - --config pr-pipeline.yml \ - --load-vars-from config-concourse.yml \ - --var ci-image-tag="pr-test" \ - --var pipeline-name="$pipeline_name" \ - --var pr.number="$pr_number" \ - --var pr.base-branch="$(jq -r '.baseRefName' <<< "$pr_info")" \ - --var pr.commit="$(jq -r '.headRefOid' <<< "$pr_info")" -} - -main() { - pushd "$(dirname "$0")/../ci" >/dev/null - - case "${PIPELINE_TYPE#--}" in - "branch") - set_branch_pipeline - ;; - "pr-manager") - set_pr_manager_pipeline - ;; - "pr") - set_pr_pipeline "$2" - ;; - *) - set_branch_pipeline - set_pr_manager_pipeline - ;; - esac - - popd >/dev/null -} - -main "$@"