Skip to content

Commit e0371b5

Browse files
committed
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.
1 parent 737beb5 commit e0371b5

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

Jenkinsfile

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ pipeline {
3939
}
4040
stage("Test other configurations") {
4141
parallel {
42-
stage("Test: springnext (jdk8)") {
43-
agent {
44-
docker {
45-
image 'adoptopenjdk/openjdk8:latest'
46-
args '-v $HOME/.m2:/root/.m2'
47-
}
48-
}
49-
steps {
50-
sh "PROFILE=springnext,convergence ci/test.sh"
51-
}
52-
}
5342
stage("Test: spring-buildsnapshot (jdk8)") {
5443
agent {
5544
docker {
@@ -121,11 +110,8 @@ pipeline {
121110

122111
steps {
123112
script {
124-
// Warm up this plugin quietly before using it.
125-
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
126-
127113
PROJECT_VERSION = sh(
128-
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
114+
script: "ci/version.sh",
129115
returnStdout: true
130116
).trim()
131117

@@ -174,11 +160,8 @@ pipeline {
174160

175161
steps {
176162
script {
177-
// Warm up this plugin quietly before using it.
178-
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
179-
180163
PROJECT_VERSION = sh(
181-
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
164+
script: "ci/version.sh",
182165
returnStdout: true
183166
).trim()
184167

@@ -209,11 +192,8 @@ pipeline {
209192

210193
steps {
211194
script {
212-
// Warm up this plugin quietly before using it.
213-
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
214-
215195
PROJECT_VERSION = sh(
216-
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
196+
script: "ci/version.sh",
217197
returnStdout: true
218198
).trim()
219199

ci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -euo pipefail
44

5-
./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B
5+
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B

ci/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -euo pipefail
44

5-
./mvnw -P${PROFILE} clean dependency:list test -Dsort -B
5+
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B

ci/version.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
RAW_VERSION=`MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
6+
org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
7+
-Dexpression=project.version -q -DforceStdout`
8+
9+
# Split things up
10+
VERSION_PARTS=($RAW_VERSION)
11+
12+
# Grab the last part, which is the actual version number.
13+
echo ${VERSION_PARTS[${#VERSION_PARTS[@]}-1]}
14+

0 commit comments

Comments
 (0)