From 5592d29f68063c154d46d91460d0e3bff090f543 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Fri, 26 Feb 2021 15:34:33 -0600 Subject: [PATCH] #1482 - Properly collection version for CI jobs. --- Jenkinsfile | 6 +----- ci/build-and-deploy-to-maven-central.sh | 2 +- ci/version.sh | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100755 ci/version.sh diff --git a/Jenkinsfile b/Jenkinsfile index e7d89684..24ea3162 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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() diff --git a/ci/build-and-deploy-to-maven-central.sh b/ci/build-and-deploy-to-maven-central.sh index d4f8b48d..81ccbb4c 100755 --- a/ci/build-and-deploy-to-maven-central.sh +++ b/ci/build-and-deploy-to-maven-central.sh @@ -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 \ No newline at end of file diff --git a/ci/version.sh b/ci/version.sh new file mode 100755 index 00000000..3e9fb1ba --- /dev/null +++ b/ci/version.sh @@ -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]} +