Skip to content

Commit 5deae38

Browse files
committed
Deploy releases directly to maven central.
To reduce risk of a release getting stuck in an intermediate state on bintray, make all official releases to maven central.
1 parent e0371b5 commit 5deae38

File tree

16 files changed

+376
-241
lines changed

16 files changed

+376
-241
lines changed

Jenkinsfile

Lines changed: 32 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pipeline {
2626
}
2727
}
2828
}
29+
2930
stage("Test: baseline (jdk8)") {
3031
agent {
3132
docker {
@@ -37,6 +38,7 @@ pipeline {
3738
sh "PROFILE=distribute,convergence ci/test.sh"
3839
}
3940
}
41+
4042
stage("Test other configurations") {
4143
parallel {
4244
stage("Test: spring-buildsnapshot (jdk8)") {
@@ -96,16 +98,21 @@ pipeline {
9698
}
9799
}
98100
}
99-
stage('Deploy to Artifactory') {
101+
102+
stage('Deploy') {
100103
agent {
101104
docker {
102-
image 'adoptopenjdk/openjdk8:latest'
103-
args '-v $HOME/.m2:/root/.m2'
105+
image 'springci/spring-ws-openjdk8-with-jq:latest'
106+
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
104107
}
105108
}
109+
options { timeout(time: 20, unit: 'MINUTES') }
106110

107111
environment {
108112
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
113+
SONATYPE = credentials('oss-token')
114+
KEYRING = credentials('spring-signing-secring.gpg')
115+
PASSPHRASE = credentials('spring-gpg-passphrase')
109116
}
110117

111118
steps {
@@ -115,94 +122,53 @@ pipeline {
115122
returnStdout: true
116123
).trim()
117124

118-
RELEASE_TYPE = 'snapshot'
119-
120125
if (PROJECT_VERSION.matches(/.*-RC[0-9]+$/) || PROJECT_VERSION.matches(/.*-M[0-9]+$/)) {
121126
RELEASE_TYPE = "milestone"
122127
} else if (PROJECT_VERSION.endsWith('SNAPSHOT')) {
123128
RELEASE_TYPE = 'snapshot'
124129
} else if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) {
125130
RELEASE_TYPE = 'release'
131+
} else {
132+
RELEASE_TYPE = 'snapshot'
126133
}
127134

128-
OUTPUT = sh(
129-
script: "PROFILE=distribute,docs,${RELEASE_TYPE} ci/build.sh",
130-
returnStdout: true
131-
).trim()
132-
133-
echo "$OUTPUT"
134-
135-
build_info_path = OUTPUT.split('\n')
136-
.find { it.contains('Artifactory Build Info Recorder') }
137-
.split('Saving Build Info to ')[1]
138-
.trim()[1..-2]
139-
140-
dir(build_info_path + '/..') {
141-
stash name: 'build_info', includes: "*.json"
142-
}
143-
}
144-
}
145-
}
146-
stage('Promote to Bintray') {
147-
when {
148-
branch 'release'
149-
}
150-
agent {
151-
docker {
152-
image 'springci/spring-ws-openjdk8-with-jq:latest'
153-
args '-v $HOME/.m2:/root/.m2'
154-
}
155-
}
156-
157-
environment {
158-
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
159-
}
160-
161-
steps {
162-
script {
163-
PROJECT_VERSION = sh(
164-
script: "ci/version.sh",
165-
returnStdout: true
166-
).trim()
167-
168-
if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) {
169-
unstash name: 'build_info'
170-
sh "ci/promote-to-bintray.sh"
135+
if (RELEASE_TYPE == 'release') {
136+
sh "PROFILE=distribute,central USERNAME=${SONATYPE_USR} PASSWORD=${SONATYPE_PSW} ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}"
171137
} else {
172-
echo "${PROJECT_VERSION} is not a candidate for promotion to Bintray."
138+
sh "PROFILE=distribute,${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh"
173139
}
174140
}
175141
}
176142
}
177-
stage('Sync to Maven Central') {
143+
144+
stage('Release documentation') {
178145
when {
179-
branch 'release'
146+
anyOf {
147+
branch 'master'
148+
branch 'release'
149+
branch 'issue/test-release'
150+
}
180151
}
181152
agent {
182153
docker {
183-
image 'springci/spring-ws-openjdk8-with-jq:latest'
184-
args '-v $HOME/.m2:/root/.m2'
154+
image 'adoptopenjdk/openjdk8:latest'
155+
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
185156
}
186157
}
158+
options { timeout(time: 20, unit: 'MINUTES') }
187159

188160
environment {
189-
BINTRAY = credentials('Bintray-spring-operator')
190-
SONATYPE = credentials('oss-token')
161+
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
191162
}
192163

193164
steps {
194165
script {
195-
PROJECT_VERSION = sh(
196-
script: "ci/version.sh",
197-
returnStdout: true
198-
).trim()
199-
200-
if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) {
201-
unstash name: 'build_info'
202-
sh "ci/sync-to-maven-central.sh"
203-
} else {
204-
echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central."
205-
}
166+
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pdistribute,docs ' +
167+
'-Dartifactory.server=https://repo.spring.io ' +
168+
"-Dartifactory.username=${ARTIFACTORY_USR} " +
169+
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
170+
"-Dartifactory.distribution-repository=temp-private-local " +
171+
'-Dmaven.test.skip=true -Dmaven.deploy.skip=true deploy -B'
206172
}
207173
}
208174
}

ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM adoptopenjdk/openjdk8:latest
22

3-
RUN apt-get update && apt-get install -y jq
3+
RUN apt-get update && apt-get install -y jq gpg
44

55
RUN apt-get clean \
66
&& rm -rf /var/lib/apt/lists/*

ci/build-and-deploy-to-artifactory.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -x
2+
3+
set -euo pipefail
4+
5+
#
6+
# Deploy the artifactory
7+
#
8+
echo 'Deploying to Artifactory...'
9+
10+
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \
11+
./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -x
2+
3+
set -euo pipefail
4+
5+
PROJECT_VERSION=$1
6+
7+
#
8+
# Stage on Maven Central
9+
#
10+
echo 'Staging on Maven Central...'
11+
12+
GNUPGHOME=/tmp/gpghome
13+
export GNUPGHOME
14+
15+
mkdir $GNUPGHOME
16+
cp $KEYRING $GNUPGHOME
17+
18+
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
19+
-s settings.xml \
20+
-P${PROFILE} \
21+
-Dmaven.test.skip=true \
22+
-Dgpg.passphrase=${PASSPHRASE} \
23+
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
24+
-DstagingDescription="Releasing ${PROJECT_VERSION}" \
25+
clean deploy -B

ci/build.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

ci/promote-to-bintray.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

ci/sync-to-maven-central.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

ci/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
set -euo pipefail
44

5-
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B
5+
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \
6+
./mvnw -P${PROFILE} clean dependency:list test -Dsort -B

docs.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 https://maven.apache.org/xsd/assembly-1.1.2.xsd">
3+
<id>docs</id>
4+
<formats>
5+
<format>dir</format>
6+
<format>zip</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<!--
12+
Adds reference manual (html and pdf) to the distribution archive
13+
under the 'docs/reference' directory see pom.xml 'maven-javadoc-plugin' declaration.
14+
-->
15+
<directory>target/site/reference</directory>
16+
<outputDirectory>reference</outputDirectory>
17+
</fileSet>
18+
<fileSet>
19+
<!--
20+
Adds javadoc html to the distribution archive under the 'docs/javadoc'
21+
directory see pom.xml 'maven-javadoc-plugin' declaration.
22+
-->
23+
<directory>target/site/apidocs</directory>
24+
<outputDirectory>api</outputDirectory>
25+
</fileSet>
26+
</fileSets>
27+
</assembly>

0 commit comments

Comments
 (0)