Building with multiple JDKs on Jenkins.
-node {
- // System Dependent Locations
- def mvnTool = tool name: 'maven3', type: 'hudson.tasks.Maven$MavenInstallation'
- def jdk9 = tool name: 'jdk9', type: 'hudson.model.JDK'
+#!groovy
+
+def oss = ["linux"]
+def jdks = ["jdk8", "jdk9", "jdk10", "jdk11"]
+
+def builds = [:]
+for (def os in oss) {
+ for (def jdk in jdks) {
+ builds[os + "_" + jdk] = newBuild(os, jdk)
+ }
+}
+
+parallel builds
- // Environment
- List mvnEnv9 = ["PATH+MVN=${mvnTool}/bin", "PATH+JDK=${jdk9}/bin", "JAVA_HOME=${jdk9}/", "MAVEN_HOME=${mvnTool}"]
- mvnEnv9.add("MAVEN_OPTS=-Xms256m -Xmx1024m -Djava.awt.headless=true")
+def newBuild(os, jdk) {
+ node(os) {
+ def mvnTool = tool name: 'maven3', type: 'hudson.tasks.Maven$MavenInstallation'
+ def jdkTool = tool name: "${jdk}", type: 'hudson.model.JDK'
+ List mvnEnv = ["PATH+MVN=${mvnTool}/bin", "PATH+JDK=${jdkTool}/bin", "JAVA_HOME=${jdkTool}/", "MAVEN_HOME=${mvnTool}"]
+ mvnEnv.add("MAVEN_OPTS=-Xms256m -Xmx1024m -Djava.awt.headless=true")
- stage('Checkout') {
+ stage("Checkout - ${jdk}") {
checkout scm
}
- stage('Build JDK 9 - Jetty 9.4.x') {
- withEnv(mvnEnv9) {
+ stage("Javadoc - ${jdk}") {
+ withEnv(mvnEnv) {
+ timeout(time: 5, unit: 'MINUTES') {
+ sh "mvn -V -B javadoc:javadoc"
+ }
+ }
+ }
+
+ stage("Build - ${jdk}") {
+ withEnv(mvnEnv) {
timeout(time: 1, unit: 'HOURS') {
- sh "mvn -B clean install -Dmaven.test.failure.ignore=true"
+ sh "mvn -V -B clean install -Dmaven.test.failure.ignore=true"
// Report failures in the jenkins UI.
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
// Collect the JaCoCo execution results.
@@ -26,12 +46,5 @@ node {
}
}
}
-
- stage('Javadoc') {
- withEnv(mvnEnv9) {
- timeout(time: 5, unit: 'MINUTES') {
- sh "mvn -B javadoc:javadoc"
- }
- }
}
}
