#1482 - Properly collection version for CI jobs.

This commit is contained in:
Greg L. Turnquist
2021-02-26 15:34:33 -06:00
parent 254a2efd55
commit 5592d29f68
3 changed files with 16 additions and 6 deletions

6
Jenkinsfile vendored
View File

@@ -123,12 +123,8 @@ pipeline {
steps {
script {
// 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'
// Extract project's version number
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',
script: "ci/version.sh",
returnStdout: true
).trim()

View File

@@ -21,5 +21,5 @@ MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
-Dmaven.test.skip=true \
-Dgpg.passphrase=${PASSPHRASE} \
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
-DstagingDescription="Releasing ${PROJECT_VERSION}" \
-DstagingDescription="Releasing Spring HATEOAS ${PROJECT_VERSION}" \
clean deploy -B

14
ci/version.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/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]}