From a938c372eaa7bc8d8d36ee448aeca5054b364226 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 29 Mar 2018 15:57:37 -0700 Subject: [PATCH] Switch to async promotion Due to timeouts while distributing release artifacts, this commit uses the async mode for distribution. Before syncing to maven central, we need to check if all the artifacts have been published to Bintray. This is done by hitting the Bintray API till we get the version or until a timeout is reached. Closes gh-12292 --- ci/pipeline.yml | 4 +++- ci/scripts/promote.sh | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 17ae69d25fc..b6782b02c0d 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -347,12 +347,14 @@ jobs: ARTIFACTORY_SERVER: ((artifactory-server)) ARTIFACTORY_USERNAME: ((artifactory-username)) ARTIFACTORY_PASSWORD: ((artifactory-password)) + BINTRAY_SUBJECT: ((bintray-subject)) + BINTRAY_REPO: ((bintray-repo)) - name: sync-to-maven-central serial: true plan: - get: spring-boot-ci-image - get: git-repo - trigger: false + trigger: true - get: artifactory-repo trigger: false passed: [promote-release] diff --git a/ci/scripts/promote.sh b/ci/scripts/promote.sh index 29c3b7e89a3..499787829e5 100755 --- a/ci/scripts/promote.sh +++ b/ci/scripts/promote.sh @@ -39,10 +39,30 @@ if [[ $RELEASE_TYPE = "RELEASE" ]]; then --max-time 2700 \ -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \ -H "Content-type:application/json" \ - -d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\"}" \ + -d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\", \"async\":\"true\"}" \ -f \ -X \ - POST "${ARTIFACTORY_SERVER}/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to publish" >&2; exit 1; } + POST "${ARTIFACTORY_SERVER}/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to distribute" >&2; exit 1; } + + echo "Waiting for artifacts to be published" + ARTIFACTS_PUBLISHED=false + WAIT_TIME=5 + COUNTER=0 + while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 24 ]; do + result=$(curl https://api.bintray.com/packages/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/$groupId ) + versions=$( echo $result | jq -r '.versions' ) + exists=$(echo $versions | grep $version) + if [ $? -eq 0 ]; then + ARTIFACTS_PUBLISHED=true + fi + COUNTER=$(( $COUNTER + 1)) + echo $COUNTER + sleep WAIT_TIME + done + if [ $ARTIFACTS_PUBLISHED == "false" ]; then + echo "Failed to publish" + exit 1 + fi fi