From e0371b5cf5042e240fd7576f301e53b910111c59 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Wed, 20 Jan 2021 14:31:07 -0600 Subject: [PATCH] Properly collect project version number for CI jobs. The outputs on Jenkins are very different than the outputs when run locally. They must be gathered in a more sophisticated fashion that grepping console logs. --- Jenkinsfile | 26 +++----------------------- ci/build.sh | 2 +- ci/test.sh | 2 +- ci/version.sh | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 25 deletions(-) create mode 100755 ci/version.sh diff --git a/Jenkinsfile b/Jenkinsfile index 39fecdb5..63e0afb4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,17 +39,6 @@ pipeline { } stage("Test other configurations") { parallel { - stage("Test: springnext (jdk8)") { - agent { - docker { - image 'adoptopenjdk/openjdk8:latest' - args '-v $HOME/.m2:/root/.m2' - } - } - steps { - sh "PROFILE=springnext,convergence ci/test.sh" - } - } stage("Test: spring-buildsnapshot (jdk8)") { agent { docker { @@ -121,11 +110,8 @@ pipeline { steps { script { - // Warm up this plugin quietly before using it. - sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version" - PROJECT_VERSION = sh( - script: "./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() @@ -174,11 +160,8 @@ pipeline { steps { script { - // Warm up this plugin quietly before using it. - sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version" - PROJECT_VERSION = sh( - script: "./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() @@ -209,11 +192,8 @@ pipeline { steps { script { - // Warm up this plugin quietly before using it. - sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version" - PROJECT_VERSION = sh( - script: "./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.sh b/ci/build.sh index 6a202bbe..619bebf6 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -2,4 +2,4 @@ set -euo pipefail -./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B diff --git a/ci/test.sh b/ci/test.sh index f6bb0bf1..9effba2f 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -2,4 +2,4 @@ set -euo pipefail -./mvnw -P${PROFILE} clean dependency:list test -Dsort -B +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B 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]} +