From 8ee2ada5ac74c19408322c28d38daab51482ccf7 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Fri, 8 Jan 2021 12:04:09 -0600 Subject: [PATCH] Deploy releases directly to maven central on the new Sonatype infrastructure.. To reduce risk of a release getting stuck in an intermediate state on bintray, make all official releases to maven central. Resolves #1180. --- Jenkinsfile | 97 ++++------ ci/Dockerfile | 2 +- ci/build-and-deploy-to-artifactory.sh | 11 ++ ci/build-and-deploy-to-maven-central.sh | 25 +++ ci/build.sh | 5 - ci/promote-to-bintray.sh | 42 ----- ci/sync-to-maven-central.sh | 23 --- ci/test.sh | 3 +- docs.xml | 27 +++ pom.xml | 226 +++++++++++++----------- settings.xml | 14 ++ spring-ws-core/pom.xml | 28 +++ spring-ws-security/pom.xml | 29 ++- spring-ws-support/pom.xml | 28 +++ spring-ws-test/pom.xml | 28 +++ spring-xml/pom.xml | 28 +++ 16 files changed, 375 insertions(+), 241 deletions(-) create mode 100755 ci/build-and-deploy-to-artifactory.sh create mode 100755 ci/build-and-deploy-to-maven-central.sh delete mode 100755 ci/build.sh delete mode 100755 ci/promote-to-bintray.sh delete mode 100755 ci/sync-to-maven-central.sh create mode 100644 docs.xml create mode 100644 settings.xml diff --git a/Jenkinsfile b/Jenkinsfile index f03f8551..e589372e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,6 +26,7 @@ pipeline { } } } + stage("Test: baseline (jdk8)") { agent { docker { @@ -37,6 +38,7 @@ pipeline { sh "PROFILE=distribute,convergence ci/test.sh" } } + stage("Test other configurations") { parallel { stage("Test: springnext (jdk8)") { @@ -162,16 +164,21 @@ pipeline { } } } - stage('Deploy to Artifactory') { + + stage('Deploy') { agent { docker { - image 'adoptopenjdk/openjdk8:latest' - args '-v $HOME/.m2:/root/.m2' + image 'springci/spring-ws-openjdk8-with-jq:latest' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } + options { timeout(time: 20, unit: 'MINUTES') } environment { ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') + SONATYPE = credentials('oss-login') + KEYRING = credentials('spring-signing-secring.gpg') + PASSPHRASE = credentials('spring-gpg-passphrase') } steps { @@ -190,36 +197,36 @@ pipeline { RELEASE_TYPE = 'snapshot' } else if (PROJECT_VERSION.endsWith('RELEASE')) { RELEASE_TYPE = 'release' + } else { + RELEASE_TYPE = 'snapshot' } - OUTPUT = sh( - script: "PROFILE=distribute,docs,${RELEASE_TYPE} ci/build.sh", - returnStdout: true - ).trim() - echo "$OUTPUT" + if (RELEASE_TYPE == 'release') { + sh "PROFILE=distribute,central USERNAME=${SONATYPE_USR} PASSWORD=${SONATYPE_PSW} ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}" - build_info_path = OUTPUT.split('\n') - .find { it.contains('Artifactory Build Info Recorder') } - .split('Saving Build Info to ')[1] - .trim()[1..-2] - - dir(build_info_path + '/..') { - stash name: 'build_info', includes: "*.json" + slackSend( + color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger', + channel: '#spring-ws', + message: "@here Spring WS ${PROJECT_VERSION} is staged on Sonatype awaiting closure and release.") + } else { + sh "PROFILE=distribute,${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh" } } } } - stage('Promote to Bintray') { + + stage('Release documentation') { when { branch 'release-3.x' } agent { docker { - image 'springci/spring-ws-openjdk8-with-jq:latest' - args '-v $HOME/.m2:/root/.m2' + image 'adoptopenjdk/openjdk8:latest' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } + options { timeout(time: 20, unit: 'MINUTES') } environment { ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') @@ -227,55 +234,13 @@ pipeline { steps { script { - // Warm up this plugin quietly before using it. - sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version" - PROJECT_VERSION = sh( - script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO", - returnStdout: true - ).trim() - - if (PROJECT_VERSION.endsWith('RELEASE')) { - unstash name: 'build_info' - sh "ci/promote-to-bintray.sh" - } else { - echo "${PROJECT_VERSION} is not a candidate for promotion to Bintray." - } - } - } - } - stage('Sync to Maven Central') { - when { - branch 'release-3.x' - } - agent { - docker { - image 'springci/spring-ws-openjdk8-with-jq:latest' - args '-v $HOME/.m2:/root/.m2' - } - } - - environment { - BINTRAY = credentials('Bintray-spring-operator') - SONATYPE = credentials('oss-token') - } - - steps { - script { - // Warm up this plugin quietly before using it. - sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version" - - PROJECT_VERSION = sh( - script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO", - returnStdout: true - ).trim() - - if (PROJECT_VERSION.endsWith('RELEASE')) { - unstash name: 'build_info' - sh "ci/sync-to-maven-central.sh" - } else { - echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central." - } + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pdistribute,docs ' + + '-Dartifactory.server=https://repo.spring.io ' + + "-Dartifactory.username=${ARTIFACTORY_USR} " + + "-Dartifactory.password=${ARTIFACTORY_PSW} " + + "-Dartifactory.distribution-repository=temp-private-local " + + '-Dmaven.test.skip=true -Dmaven.deploy.skip=true deploy -B' } } } diff --git a/ci/Dockerfile b/ci/Dockerfile index b05019dd..6f084e3c 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,6 +1,6 @@ FROM adoptopenjdk/openjdk8:latest -RUN apt-get update && apt-get install -y jq +RUN apt-get update && apt-get install -y jq gpg RUN apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/ci/build-and-deploy-to-artifactory.sh b/ci/build-and-deploy-to-artifactory.sh new file mode 100755 index 00000000..80e30e0f --- /dev/null +++ b/ci/build-and-deploy-to-artifactory.sh @@ -0,0 +1,11 @@ +#!/bin/bash -x + +set -euo pipefail + +# +# Deploy the artifactory +# +echo 'Deploying to Artifactory...' + +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \ + ./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B diff --git a/ci/build-and-deploy-to-maven-central.sh b/ci/build-and-deploy-to-maven-central.sh new file mode 100755 index 00000000..d4f8b48d --- /dev/null +++ b/ci/build-and-deploy-to-maven-central.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x + +set -euo pipefail + +PROJECT_VERSION=$1 + +# +# Stage on Maven Central +# +echo 'Staging on Maven Central...' + +GNUPGHOME=/tmp/gpghome +export GNUPGHOME + +mkdir $GNUPGHOME +cp $KEYRING $GNUPGHOME + +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \ + -s settings.xml \ + -P${PROFILE} \ + -Dmaven.test.skip=true \ + -Dgpg.passphrase=${PASSPHRASE} \ + -Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \ + -DstagingDescription="Releasing ${PROJECT_VERSION}" \ + clean deploy -B \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh deleted file mode 100755 index 6a202bbe..00000000 --- a/ci/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B diff --git a/ci/promote-to-bintray.sh b/ci/promote-to-bintray.sh deleted file mode 100755 index a00bb8d6..00000000 --- a/ci/promote-to-bintray.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e -u - -buildName=`jq -r '.name' build-info.json` -buildNumber=`jq -r '.number' build-info.json` -groupId=`jq -r '.modules[0].id' build-info.json | sed 's/\(.*\):.*:.*/\1/'` -version=`jq -r '.modules[0].id' build-info.json | sed 's/.*:.*:\(.*\)/\1/'` - -echo "Promoting ${buildName}/${buildNumber}/${groupId}/${version} to libs-release-local" - -curl \ - -s \ - --connect-timeout 240 \ - --max-time 2700 \ - -u ${ARTIFACTORY_USR}:${ARTIFACTORY_PSW} \ - -H 'Content-type:application/json' \ - -d '{"sourceRepos": ["libs-release-local"], "targetRepo" : "spring-distributions", "async":"true"}' \ - -f \ - -X \ - POST "https://repo.spring.io/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=10 -COUNTER=0 - -while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 120 ]; do - - result=$( curl -s https://api.bintray.com/packages/spring/jars/"${groupId}" ) - versions=$( echo "$result" | jq -r '.versions' ) - exists=$( echo "$versions" | grep "$version" -o || true ) - - if [ "$exists" = "$version" ]; then - ARTIFACTS_PUBLISHED=true - fi - - COUNTER=$(( COUNTER + 1 )) - sleep $WAIT_TIME - -done diff --git a/ci/sync-to-maven-central.sh b/ci/sync-to-maven-central.sh deleted file mode 100755 index a2d47e83..00000000 --- a/ci/sync-to-maven-central.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -e -u - -buildName=`jq -r '.name' build-info.json` -buildNumber=`jq -r '.number' build-info.json` -groupId=`jq -r '.modules[0].id' build-info.json | sed 's/\(.*\):.*:.*/\1/'` -version=`jq -r '.modules[0].id' build-info.json | sed 's/.*:.*:\(.*\)/\1/'` - -echo "Synching ${buildName}/${buildNumber}/${groupId}/${version} to Maven Central..." - -curl \ - -s \ - --connect-timeout 240 \ - --max-time 2700 \ - -u ${BINTRAY_USR}:${BINTRAY_PSW} \ - -H 'Content-Type: application/json' \ - -d "{ \"username\": \"${SONATYPE_USR}\", \"password\": \"${SONATYPE_PSW}\"}" \ - -f \ - -X \ - POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } - -echo "Sync complete" diff --git a/ci/test.sh b/ci/test.sh index f6bb0bf1..6ff29373 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -2,4 +2,5 @@ set -euo pipefail -./mvnw -P${PROFILE} clean dependency:list test -Dsort -B +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \ + ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B diff --git a/docs.xml b/docs.xml new file mode 100644 index 00000000..f8b41cba --- /dev/null +++ b/docs.xml @@ -0,0 +1,27 @@ + + + docs + + dir + zip + + false + + + + target/site/reference + reference + + + + target/site/apidocs + api + + + diff --git a/pom.xml b/pom.xml index d6577309..d77de815 100644 --- a/pom.xml +++ b/pom.xml @@ -501,45 +501,85 @@ - release + central + + + true + true + true + true + true + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + sonatype + https://s01.oss.sonatype.org/ + false + true + true + + + + + + + - org.jfrog.buildinfo - artifactory-maven-plugin - 2.6.1 - false - - - build-info - - publish - - - - {{BUILD_URL}} - - - spring-ws - spring-ws - false - docs - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-release-local - libs-release-local - - - - + org.apache.maven.plugins + maven-gpg-plugin + + + org.sonatype.plugins + nexus-staging-maven-plugin + + + + + + + sonatype + https://s01.oss.sonatype.org//service/local/staging/deploy/maven2/ + + + @@ -671,83 +711,82 @@ aggregate - aggregate-jar + aggregate prepare-package false + + ${project.root}/target/site/apidocs + + + + attach-javadocs + + jar + + + + org.apache.maven.plugins - maven-antrun-plugin - - - ant-contrib - ant-contrib - 1.0b3 - - - ant - ant - - - - - org.apache.ant - ant-nodeps - 1.8.1 - - - org.tigris.antelope - antelopetasks - 3.2.10 - - + maven-assembly-plugin - package-and-attach-docs-zip + docs - run + single package - false - - - - - - - + + docs.xml + + spring-ws-${project.version} + true + - org.codehaus.mojo - build-helper-maven-plugin - 1.10 - false + org.jfrog.buildinfo + artifactory-maven-plugin + 2.6.1 - attach-zip + deploy-docs - attach-artifact + publish + deploy - - - - ${project.build.directory}/${project.artifactId}-${project.version}.zip - - zip;zip.type=docs;zip.deployed=false - - + + false + + + spring-ws-docs + spring-ws-docs + false + docs + + + + Spring Docs spring-ws ${project.version} + 1 + + + {{artifactory.server}} + {{artifactory.username}} + {{artifactory.password}} + {{artifactory.distribution-repository}} + {{artifactory.distribution-repository}} + *-docs.zip + @@ -756,23 +795,6 @@ - - central - - - - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - sonatype-nexus-staging - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - java11 diff --git a/settings.xml b/settings.xml new file mode 100644 index 00000000..7368837c --- /dev/null +++ b/settings.xml @@ -0,0 +1,14 @@ + + + + + sonatype + ${env.USERNAME} + ${env.PASSWORD} + + + + \ No newline at end of file diff --git a/spring-ws-core/pom.xml b/spring-ws-core/pom.xml index bb17c2ee..5423027c 100644 --- a/spring-ws-core/pom.xml +++ b/spring-ws-core/pom.xml @@ -202,4 +202,32 @@ + + + docs + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + docs + + single + + package + + true + + + + + + + + + + \ No newline at end of file diff --git a/spring-ws-security/pom.xml b/spring-ws-security/pom.xml index 9aee83c2..b4779c90 100644 --- a/spring-ws-security/pom.xml +++ b/spring-ws-security/pom.xml @@ -208,7 +208,34 @@ - + + + docs + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + docs + + single + + package + + true + + + + + + + + + + \ No newline at end of file diff --git a/spring-ws-support/pom.xml b/spring-ws-support/pom.xml index 3923733d..43a05c87 100644 --- a/spring-ws-support/pom.xml +++ b/spring-ws-support/pom.xml @@ -127,4 +127,32 @@ + + + docs + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + docs + + single + + package + + true + + + + + + + + + + \ No newline at end of file diff --git a/spring-ws-test/pom.xml b/spring-ws-test/pom.xml index a73b5bcb..4919cfa2 100644 --- a/spring-ws-test/pom.xml +++ b/spring-ws-test/pom.xml @@ -48,4 +48,32 @@ + + + docs + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + docs + + single + + package + + true + + + + + + + + + + \ No newline at end of file diff --git a/spring-xml/pom.xml b/spring-xml/pom.xml index b71d3b40..0a784644 100644 --- a/spring-xml/pom.xml +++ b/spring-xml/pom.xml @@ -41,4 +41,32 @@ + + + docs + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + docs + + single + + package + + true + + + + + + + + + + \ No newline at end of file