Ship releases using Jenkins
See gh-719
This commit is contained in:
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
@@ -68,35 +68,47 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Release to artifactory') {
|
||||
stage('Deploy') {
|
||||
when {
|
||||
beforeAgent(true)
|
||||
anyOf {
|
||||
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
|
||||
branch(pattern: "main|(\\d\\.\\d\\.x)|v(\\d\\.\\d\\.d)|", comparator: "REGEXP")
|
||||
not { triggeredBy 'UpstreamCause' }
|
||||
}
|
||||
}
|
||||
agent {
|
||||
label 'data'
|
||||
docker {
|
||||
image "harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-vault-openjdk17-vault:${p['java.main.tag']}-${p['docker.vault.version']}"
|
||||
args "${p['docker.java.inside.basic']}"
|
||||
}
|
||||
}
|
||||
options { timeout(time: 20, unit: 'MINUTES') }
|
||||
|
||||
environment {
|
||||
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
|
||||
SONATYPE = credentials('oss-login')
|
||||
KEYRING = credentials('spring-signing-secring.gpg')
|
||||
PASSPHRASE = credentials('spring-gpg-passphrase')
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
docker.image("harbor-repo.vmware.com/dockerhub-proxy-cache/springci/spring-vault-openjdk8-vault:${p['java.main.tag']}-${p['docker.vault.version']}").inside(p['docker.java.inside.basic']) {
|
||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory ' +
|
||||
'-Dartifactory.server=https://repo.spring.io ' +
|
||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||
"-Dartifactory.build-name=spring-vault " +
|
||||
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||
PROJECT_VERSION = sh(
|
||||
script: "ci/version.sh",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
RELEASE_TYPE = 'snapshot'
|
||||
|
||||
if (PROJECT_VERSION.matches(/.*-RC[0-9]+$/) || PROJECT_VERSION.matches(/.*-M[0-9]+$/)) {
|
||||
RELEASE_TYPE = "milestone"
|
||||
} else if (PROJECT_VERSION.endsWith('SNAPSHOT')) {
|
||||
RELEASE_TYPE = 'snapshot'
|
||||
} else if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) {
|
||||
RELEASE_TYPE = 'release'
|
||||
}
|
||||
|
||||
sh "ci/deploy-${RELEASE_TYPE}.sh"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
ci/deploy-milestone.sh
Executable file
19
ci/deploy-milestone.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,milestone,artifactory,release \
|
||||
-Dartifactory.server=https://repo.spring.io \
|
||||
-Dartifactory.username=${ARTIFACTORY_USR} \
|
||||
-Dartifactory.password=${ARTIFACTORY_PSW} \
|
||||
-Dartifactory.staging-repository=libs-milestone-local \
|
||||
-Dartifactory.build-name=spring-vault \
|
||||
-Dartifactory.build-number=${BUILD_NUMBER} \
|
||||
clean deploy -U -B
|
||||
|
||||
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pdistribute \
|
||||
-Dartifactory.server=https://repo.spring.io \
|
||||
-Dartifactory.username=${ARTIFACTORY_USR} \
|
||||
-Dartifactory.password=${ARTIFACTORY_PSW} \
|
||||
-Dartifactory.staging-repository=temp-private-local \
|
||||
clean deploy -U -B
|
||||
22
ci/deploy-release.sh
Executable file
22
ci/deploy-release.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GNUPGHOME=/tmp/gpghome
|
||||
export GNUPGHOME
|
||||
|
||||
mkdir $GNUPGHOME
|
||||
cp $KEYRING $GNUPGHOME
|
||||
|
||||
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,central,release \
|
||||
-Dgpg.passphrase=${PASSPHRASE} \
|
||||
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
|
||||
-DstagingDescription="Releasing Spring Vault ${VERSION}" \
|
||||
clean deploy -U -B
|
||||
|
||||
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pdistribute \
|
||||
-Dartifactory.server=https://repo.spring.io \
|
||||
-Dartifactory.username=${ARTIFACTORY_USR} \
|
||||
-Dartifactory.password=${ARTIFACTORY_PSW} \
|
||||
-Dartifactory.staging-repository=temp-private-local \
|
||||
clean deploy -U -B
|
||||
12
ci/deploy-snapshot.sh
Executable file
12
ci/deploy-snapshot.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,snapshot,artifactory \
|
||||
-Dartifactory.server=https://repo.spring.io \
|
||||
-Dartifactory.username=${ARTIFACTORY_USR} \
|
||||
-Dartifactory.password=${ARTIFACTORY_PSW} \
|
||||
-Dartifactory.staging-repository=libs-snapshot-local \
|
||||
-Dartifactory.build-name=spring-vault \
|
||||
-Dartifactory.build-number=${BUILD_NUMBER} \
|
||||
-Dmaven.test.skip=true \
|
||||
clean deploy -U -B
|
||||
13
ci/version.sh
Executable file
13
ci/version.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
RAW_VERSION=`MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
|
||||
org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
|
||||
-Dexpression=project.version -q -DforceStdout`
|
||||
|
||||
# Split things up
|
||||
VERSION_PARTS=($RAW_VERSION)
|
||||
|
||||
# Grab the last part, which is the actual version number.
|
||||
echo ${VERSION_PARTS[${#VERSION_PARTS[@]}-1]}
|
||||
51
pom.xml
51
pom.xml
@@ -619,6 +619,20 @@
|
||||
</repositories>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
|
||||
<id>snapshot</id>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
|
||||
<id>milestone</id>
|
||||
@@ -679,6 +693,35 @@
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-no-third-party-snapshots</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireReleaseDeps />
|
||||
<NoSnapshotDependenciesInDependencyManagementRule implementation="de.smartics.maven.enforcer.rule.NoSnapshotsInDependencyManagementRule">
|
||||
<onlyWhenRelease>true</onlyWhenRelease>
|
||||
</NoSnapshotDependenciesInDependencyManagementRule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.smartics.rules</groupId>
|
||||
<artifactId>smartics-enforcer-rules</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
@@ -815,14 +858,6 @@
|
||||
|
||||
<id>artifactory</id>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
<username>${env.ARTIFACTORY_USR}</username>
|
||||
<password>${env.ARTIFACTORY_PSW}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<username>${env.SONATYPE_USR}</username>
|
||||
<password>${env.SONATYPE_PSW}</password>
|
||||
</server>
|
||||
</servers>
|
||||
|
||||
</settings>
|
||||
</settings>
|
||||
|
||||
@@ -221,6 +221,20 @@
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
<id>snapshot</id>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
|
||||
<id>milestone</id>
|
||||
@@ -268,7 +282,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
@@ -288,14 +302,6 @@
|
||||
|
||||
<id>artifactory</id>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<name>Spring Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
@@ -348,6 +354,41 @@
|
||||
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-no-third-party-snapshots</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireReleaseDeps />
|
||||
<NoSnapshotDependenciesInDependencyManagementRule implementation="de.smartics.maven.enforcer.rule.NoSnapshotsInDependencyManagementRule">
|
||||
<onlyWhenRelease>true</onlyWhenRelease>
|
||||
</NoSnapshotDependenciesInDependencyManagementRule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.smartics.rules</groupId>
|
||||
<artifactId>smartics-enforcer-rules</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -427,13 +427,14 @@
|
||||
<!-- Retain only a single build -->
|
||||
<buildName>Spring Vault Docs ${project.version}</buildName>
|
||||
<buildRetentionCount>1</buildRetentionCount>
|
||||
<buildUrl>{{BUILD_URL}}</buildUrl>
|
||||
</buildInfo>
|
||||
<publisher>
|
||||
<contextUrl>https://repo.spring.io</contextUrl>
|
||||
<username>${artifactory.username}</username>
|
||||
<password>${artifactory.password}</password>
|
||||
<repoKey>temp-private-local</repoKey>
|
||||
<snapshotRepoKey>temp-private-local</snapshotRepoKey>
|
||||
<contextUrl>{{artifactory.server}}</contextUrl>
|
||||
<username>{{artifactory.username}}</username>
|
||||
<password>{{artifactory.password}}</password>
|
||||
<repoKey>{{artifactory.staging-repository}}</repoKey>
|
||||
<snapshotRepoKey>{{artifactory.staging-repository}}</snapshotRepoKey>
|
||||
<includePatterns>*.zip</includePatterns>
|
||||
</publisher>
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user