diff --git a/ci/pipeline.yml b/ci/pipeline.yml index eca0df7673..1dbda00858 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -345,6 +345,19 @@ jobs: ARTIFACTORY_SERVER: ((artifactory-server)) ARTIFACTORY_USERNAME: ((artifactory-username)) ARTIFACTORY_PASSWORD: ((artifactory-password)) +- name: sync-to-maven-central + serial: true + plan: + - get: spring-boot-ci-image + - get: git-repo + trigger: false + - get: artifactory-repo + trigger: false + passed: [promote-release] + - task: sync-to-maven-central + image: spring-boot-ci-image + file: git-repo/ci/tasks/sync-to-maven-central.yml + params: BINTRAY_USERNAME: ((bintray-username)) BINTRAY_PASSWORD: ((bintray-password)) SONATYPE_USERNAME: ((sonatype-username)) @@ -355,7 +368,7 @@ groups: - name: "Build" jobs: ["build", "jdk9-build", "jdk10-build"] - name: "Release" - jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release"] + jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "sync-to-maven-central"] - name: "CI Images" jobs: ["build-spring-boot-ci-images"] - name: "Build Pull Requests" diff --git a/ci/scripts/promote.sh b/ci/scripts/promote.sh index c215bc3a9f..29c3b7e89a 100755 --- a/ci/scripts/promote.sh +++ b/ci/scripts/promote.sh @@ -43,16 +43,6 @@ if [[ $RELEASE_TYPE = "RELEASE" ]]; then -f \ -X \ POST "${ARTIFACTORY_SERVER}/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to publish" >&2; exit 1; } - - curl \ - -s \ - --connect-timeout 240 \ - --max-time 2700 \ - -u ${BINTRAY_USERNAME}:${BINTRAY_PASSWORD} \ - -H "Content-Type: application/json" -d "{\"username\": \"${SONATYPE_USERNAME}\", \"password\": \"${SONATYPE_PASSWORD}\"}" \ - -f \ - -X \ - POST "https://api.bintray.com/maven_central_sync/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } fi diff --git a/ci/scripts/sync-to-maven-central.sh b/ci/scripts/sync-to-maven-central.sh new file mode 100755 index 0000000000..d644c3bf9c --- /dev/null +++ b/ci/scripts/sync-to-maven-central.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' ) +buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' ) +groupId=$( 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/' ) + +echo "Syncing ${buildName}/${buildNumber} to Maven Central" + curl \ + -s \ + --connect-timeout 240 \ + --max-time 2700 \ + -u ${BINTRAY_USERNAME}:${BINTRAY_PASSWORD} \ + -H "Content-Type: application/json" -d "{\"username\": \"${SONATYPE_USERNAME}\", \"password\": \"${SONATYPE_PASSWORD}\"}" \ + -f \ + -X \ + POST "https://api.bintray.com/maven_central_sync/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } +echo "Sync complete" \ No newline at end of file diff --git a/ci/tasks/sync-to-maven-central.yml b/ci/tasks/sync-to-maven-central.yml new file mode 100644 index 0000000000..e267c6735b --- /dev/null +++ b/ci/tasks/sync-to-maven-central.yml @@ -0,0 +1,7 @@ +--- +platform: linux +inputs: +- name: git-repo +- name: artifactory-repo +run: + path: git-repo/ci/scripts/sync-to-maven-central.sh