From 4894affbb66e2d62599bbe62e3f640c36f37fcd9 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sun, 16 Jun 2019 21:00:31 -0700 Subject: [PATCH] Allow maven central sync to run several times Update the "sync to maven central" CI job so that it can be rerun if necessary. We now first check if artifacts are already published before triggering the sync from Bintray. Closes gh-16866 --- ci/scripts/sync-to-maven-central.sh | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ci/scripts/sync-to-maven-central.sh b/ci/scripts/sync-to-maven-central.sh index 88924ac826..b92ee0ade9 100755 --- a/ci/scripts/sync-to-maven-central.sh +++ b/ci/scripts/sync-to-maven-central.sh @@ -7,14 +7,28 @@ groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].i version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) echo "Syncing ${buildName}/${buildNumber} to Maven Central" - curl \ + + publishStatus=$(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}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } + -o /dev/null \ + -I \ + -w "%{http_code}" + "https://oss.sonatype.org/service/local/repositories/releases/content/org/springframework/boot/spring-boot/${version}/spring-boot-${version}.jar.sha1") + + if [ ${publishStatus} == "200" ]; then + echo "Already published to Sonatype" + else + echo "Calling Bintray to sync to Sonatype" + 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}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } + fi + echo "Sync complete" echo $version > version/version