#1417 - Release directly to maven central.
By removing our need to use bintray for releases and instead deploying directly to maven central, we can reduce the risk of issues.
This commit is contained in:
109
Jenkinsfile
vendored
109
Jenkinsfile
vendored
@@ -36,7 +36,6 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=none ci/test.sh'
|
||||
}
|
||||
}
|
||||
@@ -52,7 +51,6 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=none ci/test.sh'
|
||||
}
|
||||
}
|
||||
@@ -65,7 +63,6 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=none ci/test.sh'
|
||||
}
|
||||
}
|
||||
@@ -78,7 +75,6 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=spring-next ci/test.sh'
|
||||
}
|
||||
}
|
||||
@@ -91,7 +87,6 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=spring-next ci/test.sh'
|
||||
}
|
||||
}
|
||||
@@ -104,14 +99,13 @@ pipeline {
|
||||
}
|
||||
options { timeout(time: 30, unit: 'MINUTES') }
|
||||
steps {
|
||||
sh 'rm -rf ?'
|
||||
sh 'PROFILE=spring-next ci/test.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to Artifactory') {
|
||||
stage('Deploy') {
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-hateoas-openjdk8-with-graphviz-and-jq:latest'
|
||||
@@ -122,12 +116,13 @@ pipeline {
|
||||
|
||||
environment {
|
||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||
SONATYPE = credentials('oss-token')
|
||||
KEYRING = credentials('spring-signing-secring.gpg')
|
||||
PASSPHRASE = credentials('spring-gpg-passphrase')
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
sh 'rm -rf ?'
|
||||
|
||||
// Warm up this plugin quietly before using it.
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version'
|
||||
|
||||
@@ -147,23 +142,10 @@ pipeline {
|
||||
RELEASE_TYPE = 'release'
|
||||
}
|
||||
|
||||
// Capture build output...
|
||||
OUTPUT = sh(
|
||||
script: "PROFILE=ci,${RELEASE_TYPE} ci/build.sh",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
echo "$OUTPUT"
|
||||
|
||||
// ...to extract artifactory build info
|
||||
build_info_path = OUTPUT.split('\n')
|
||||
.find { it.contains('Artifactory Build Info Recorder') }
|
||||
.split('Saving Build Info to ')[1]
|
||||
.trim()[1..-2]
|
||||
|
||||
// Stash the JSON build info to support promotion to bintray
|
||||
dir(build_info_path + '/..') {
|
||||
stash name: 'build_info', includes: "*.json"
|
||||
if (RELEASE_TYPE == 'release') {
|
||||
sh "PROFILE=ci,central ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}"
|
||||
} else {
|
||||
sh "PROFILE=ci,${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,81 +180,6 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Promote to Bintray') {
|
||||
when {
|
||||
branch 'release'
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-hateoas-openjdk8-with-graphviz-and-jq:latest'
|
||||
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
|
||||
}
|
||||
}
|
||||
options { timeout(time: 20, unit: 'MINUTES') }
|
||||
|
||||
environment {
|
||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
sh 'rm -rf ?'
|
||||
|
||||
// Warm up this plugin quietly before using it.
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version'
|
||||
|
||||
PROJECT_VERSION = sh(
|
||||
script: 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./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.matches(/.*\.[0-9]+$/)) {
|
||||
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'
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'springci/spring-hateoas-openjdk8-with-graphviz-and-jq:latest'
|
||||
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
|
||||
}
|
||||
}
|
||||
options { timeout(time: 20, unit: 'MINUTES') }
|
||||
|
||||
environment {
|
||||
BINTRAY = credentials('Bintray-spring-operator')
|
||||
SONATYPE = credentials('oss-token')
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
sh 'rm -rf ?'
|
||||
|
||||
// Warm up this plugin quietly before using it.
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version'
|
||||
|
||||
PROJECT_VERSION = sh(
|
||||
script: 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./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.matches(/.*\.[0-9]+$/)) {
|
||||
unstash name: 'build_info'
|
||||
sh "ci/sync-to-maven-central.sh"
|
||||
} else {
|
||||
echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM adoptopenjdk/openjdk8:latest
|
||||
|
||||
RUN apt-get update && apt-get install -y graphviz jq
|
||||
RUN apt-get update && apt-get install -y graphviz jq gpg
|
||||
|
||||
RUN apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -2,4 +2,9 @@
|
||||
|
||||
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
|
||||
25
ci/build-and-deploy-to-maven-central.sh
Executable file
25
ci/build-and-deploy-to-maven-central.sh
Executable file
@@ -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
|
||||
@@ -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
|
||||
@@ -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 "Syncing ${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"
|
||||
86
pom.xml
86
pom.xml
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.hateoas</groupId>
|
||||
@@ -292,7 +292,7 @@
|
||||
<fileset dir="src/main/asciidoc" includes="**/*.adoc"/>
|
||||
</copy>
|
||||
<copy failonerror="false"
|
||||
todir="${generated-asciidoc-sources.directory}/images/">
|
||||
todir="${generated-asciidoc-sources.directory}/images/">
|
||||
<fileset dir="src/main/asciidoc/images"/>
|
||||
</copy>
|
||||
|
||||
@@ -317,7 +317,7 @@
|
||||
|
||||
<!-- Copy files for the single-file HTML version -->
|
||||
<copy failonerror="false"
|
||||
todir="target/site/reference/html/images">
|
||||
todir="target/site/reference/html/images">
|
||||
<fileset dir="${generated-docs.directory}/images"/>
|
||||
</copy>
|
||||
|
||||
@@ -342,11 +342,11 @@
|
||||
|
||||
<!-- Copy and rename the Epub file -->
|
||||
<copy failonerror="false" file="${generated-docs.directory}/index.pdf"
|
||||
tofile="target/site/reference/pdf/spring-hateoas-reference.pdf"/>
|
||||
tofile="target/site/reference/pdf/spring-hateoas-reference.pdf"/>
|
||||
|
||||
<!-- Copy and rename the PDF file -->
|
||||
<copy failonerror="false" file="${generated-docs.directory}/index.epub"
|
||||
tofile="target/site/reference/epub/spring-hateoas-reference.epub"/>
|
||||
tofile="target/site/reference/epub/spring-hateoas-reference.epub"/>
|
||||
|
||||
</target>
|
||||
</configuration>
|
||||
@@ -661,6 +661,80 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>central</id>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
||||
<!-- Sign JARs -->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<gpgArguments>
|
||||
<arg>--pinentry-mode</arg>
|
||||
<arg>loopback</arg>
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Deploy to Sonatype OSS Nexus -->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>sonatype</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
<keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
|
||||
<skipStagingRepositoryClose>false</skipStagingRepositoryClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</profile>
|
||||
|
||||
|
||||
</profiles>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -865,7 +939,7 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<optional>true</optional>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
12
settings.xml
Normal file
12
settings.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
|
||||
<servers>
|
||||
<server>
|
||||
<id>sonatype</id>
|
||||
<username>${env.SONATYPE_USR}</username>
|
||||
<password>${env.SONATYPE_PSW}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
Reference in New Issue
Block a user