Skip to content

Commit 4894aff

Browse files
committed
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
1 parent 84c6313 commit 4894aff

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

ci/scripts/sync-to-maven-central.sh

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@ groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].i
77
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
88

99
echo "Syncing ${buildName}/${buildNumber} to Maven Central"
10-
curl \
10+
11+
publishStatus=$(curl \
1112
-s \
12-
--connect-timeout 240 \
13-
--max-time 2700 \
14-
-u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \
15-
-H "Content-Type: application/json" -d "{\"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \
16-
-f \
17-
-X \
18-
POST "https://api.bintray.com/maven_central_sync/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
13+
-o /dev/null \
14+
-I \
15+
-w "%{http_code}"
16+
"https://oss.sonatype.org/service/local/repositories/releases/content/org/springframework/boot/spring-boot/${version}/spring-boot-${version}.jar.sha1")
17+
18+
if [ ${publishStatus} == "200" ]; then
19+
echo "Already published to Sonatype"
20+
else
21+
echo "Calling Bintray to sync to Sonatype"
22+
curl \
23+
-s \
24+
--connect-timeout 240 \
25+
--max-time 2700 \
26+
-u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \
27+
-H "Content-Type: application/json" -d "{\"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \
28+
-f \
29+
-X \
30+
POST "https://api.bintray.com/maven_central_sync/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
31+
fi
32+
1933
echo "Sync complete"
2034
echo $version > version/version

0 commit comments

Comments
 (0)