Skip to content

Commit 98e2504

Browse files
committed
CASSANDRA-19504: Improve state management for Java versions in Jenkinsfile
patch by Bret McGuire; reviewed by Bret McGuire for CASSANDRA-19504
1 parent 40a9a49 commit 98e2504

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Jenkinsfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ def initializeEnvironment() {
6161
. ${JABBA_SHELL}
6262
jabba which 1.8''', returnStdout: true).trim()
6363

64-
env.TEST_JAVA_HOME = sh(label: 'Get TEST_JAVA_HOME',script: '''#!/bin/bash -le
65-
. ${JABBA_SHELL}
66-
jabba which ${JABBA_VERSION}''', returnStdout: true).trim()
67-
env.TEST_JAVA_VERSION = sh(label: 'Get TEST_JAVA_VERSION',script: '''#!/bin/bash -le
68-
echo "${JABBA_VERSION##*.}"''', returnStdout: true).trim()
69-
7064
sh label: 'Download Apache CassandraⓇ or DataStax Enterprise',script: '''#!/bin/bash -le
7165
. ${JABBA_SHELL}
7266
jabba use 1.8
@@ -115,7 +109,12 @@ def buildDriver(jabbaVersion) {
115109
}
116110

117111
def executeTests() {
118-
sh label: 'Execute tests', script: '''#!/bin/bash -le
112+
def testJavaHome = sh(label: 'Get TEST_JAVA_HOME',script: '''#!/bin/bash -le
113+
. ${JABBA_SHELL}
114+
jabba which ${JABBA_VERSION}''', returnStdout: true).trim()
115+
def testJavaVersion = (JABBA_VERSION =~ /.*\.(\d+)/)[0][1]
116+
117+
def executeTestScript = '''#!/bin/bash -le
119118
# Load CCM environment variables
120119
set -o allexport
121120
. ${HOME}/environment.txt
@@ -137,8 +136,8 @@ def executeTests() {
137136
printenv | sort
138137
139138
mvn -B -V ${INTEGRATION_TESTS_FILTER_ARGUMENT} -T 1 verify \
140-
-Ptest-jdk-${TEST_JAVA_VERSION} \
141-
-DtestJavaHome=${TEST_JAVA_HOME} \
139+
-Ptest-jdk-'''+testJavaVersion+''' \
140+
-DtestJavaHome='''+testJavaHome+''' \
142141
-DfailIfNoTests=false \
143142
-Dmaven.test.failure.ignore=true \
144143
-Dmaven.javadoc.skip=${SKIP_JAVADOCS} \
@@ -149,6 +148,8 @@ def executeTests() {
149148
${ISOLATED_ITS_ARGUMENT} \
150149
${PARALLELIZABLE_ITS_ARGUMENT}
151150
'''
151+
echo "Invoking Maven with parameters test-jdk-${testJavaVersion} and testJavaHome = ${testJavaHome}"
152+
sh label: 'Execute tests', script: executeTestScript
152153
}
153154

154155
def executeCodeCoverage() {

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ limitations under the License.]]></inlineHeader>
728728
<plugin>
729729
<artifactId>maven-surefire-plugin</artifactId>
730730
<configuration>
731+
<jvm>${testing.jvm}/bin/java</jvm>
731732
<systemPropertyVariables>
732733
<logback.configurationFile>${project.basedir}/src/test/resources/logback-test.xml</logback.configurationFile>
733734
</systemPropertyVariables>

0 commit comments

Comments
 (0)