From 67a6ad47b03f426361b2cecb362e9c7e7a5f2789 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 12 Nov 2018 10:12:15 -0600 Subject: [PATCH 1/2] Using new Declarative Jenkinsfile format + Makes things easier to maintain. + Does not solve for bad "unstable" flagging of multiple stages when only one is failing. See: https://issues.jenkins-ci.org/browse/JENKINS-39203 But this Declarative format will help once that bug is fixed. Signed-off-by: Joakim Erdfelt --- Jenkinsfile | 160 ++++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 79 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 09071967d8d..530b3a8deda 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,95 +1,97 @@ #!groovy -def mainJdk = "jdk8" -def jdks = [mainJdk, "jdk11"] -def oss = ["linux"] -def builds = [:] -for (def os in oss) { - for (def jdk in jdks) { - builds[os+"_"+jdk] = getFullBuild( jdk, os, mainJdk == jdk ) - } -} +pipeline { + agent any + stages { + stage("Parallel Stage") { + parallel { + stage("Build / Test - JDK8") { + agent { node { label 'linux' } } + options { timeout(time: 120, unit: 'MINUTES') } + steps { + mavenBuild("jdk8", "-Pmongodb install") + junit '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml' + // Collect up the jacoco execution results (only on main build) + jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class', + exclusionPattern: '' + + // build tools + '**/org/eclipse/jetty/ant/**' + + ',**/org/eclipse/jetty/maven/**' + + ',**/org/eclipse/jetty/jspc/**' + + // example code / documentation + ',**/org/eclipse/jetty/embedded/**' + + ',**/org/eclipse/jetty/asyncrest/**' + + ',**/org/eclipse/jetty/demo/**' + + // special environments / late integrations + ',**/org/eclipse/jetty/gcloud/**' + + ',**/org/eclipse/jetty/infinispan/**' + + ',**/org/eclipse/jetty/osgi/**' + + ',**/org/eclipse/jetty/spring/**' + + ',**/org/eclipse/jetty/http/spi/**' + + // test classes + ',**/org/eclipse/jetty/tests/**' + + ',**/org/eclipse/jetty/test/**', + execPattern: '**/target/jacoco.exec', + classPattern: '**/target/classes', + sourcePattern: '**/src/main/java' + warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] -parallel builds - -def getFullBuild(jdk, os, mainJdk) { - return { - node(os) { - // System Dependent Locations - def mvnName = 'maven3.5' - def localRepo = "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}" // ".repository" // - def settingsName = 'oss-settings.xml' - def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true' - - stage("Build / Test - $jdk") { - timeout(time: 120, unit: 'MINUTES') { - // Checkout - checkout scm - withMaven( - maven: mvnName, - jdk: "$jdk", - publisherStrategy: 'EXPLICIT', - globalMavenSettingsConfig: settingsName, - mavenOpts: mavenOpts, - mavenLocalRepo: localRepo) { - // Testing - sh "mvn -V -B install -Dmaven.test.failure.ignore=true -T5 -e -Djetty.testtracker.log=true -Pmongodb -Dunix.socket.tmp=" + env.JENKINS_HOME - // Javadoc only - sh "mvn -V -B javadoc:javadoc -T6 -e -Dmaven.test.failure.ignore=false" + script { + step([$class : 'MavenInvokerRecorder', reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", + invokerBuildDir: "**/target/its"]) + } } } - // Report failures in the jenkins UI - junit testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml' - consoleParsers = [[parserName: 'JavaDoc'], - [parserName: 'JavaC']] - - if (mainJdk) { - // Collect up the jacoco execution results - def jacocoExcludes = - // build tools - "**/org/eclipse/jetty/ant/**" + ",**/org/eclipse/jetty/maven/**" + - ",**/org/eclipse/jetty/jspc/**" + - // example code / documentation - ",**/org/eclipse/jetty/embedded/**" + ",**/org/eclipse/jetty/asyncrest/**" + - ",**/org/eclipse/jetty/demo/**" + - // special environments / late integrations - ",**/org/eclipse/jetty/gcloud/**" + ",**/org/eclipse/jetty/infinispan/**" + - ",**/org/eclipse/jetty/osgi/**" + ",**/org/eclipse/jetty/spring/**" + - ",**/org/eclipse/jetty/http/spi/**" + - // test classes - ",**/org/eclipse/jetty/tests/**" + ",**/org/eclipse/jetty/test/**" - jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class', - exclusionPattern: jacocoExcludes, - execPattern: '**/target/jacoco.exec', - classPattern: '**/target/classes', - sourcePattern: '**/src/main/java' - consoleParsers = [[parserName: 'Maven'], - [parserName: 'JavaDoc'], - [parserName: 'JavaC']] - - step([$class: 'MavenInvokerRecorder', reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml", - invokerBuildDir: "**/target/its"]) + stage("Build / Test - JDK11") { + agent { node { label 'linux' } } + options { timeout(time: 120, unit: 'MINUTES') } + steps { + mavenBuild("jdk11", "-Pmongodb install") + junit '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml' + warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] + } } - // Report on Maven and Javadoc warnings - step([$class : 'WarningsPublisher', - consoleParsers: consoleParsers]) - } + stage("Build Javadoc") { + agent { node { label 'linux' } } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + mavenBuild("jdk8", "javadoc:javadoc") + warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']] + } + } - stage ("Compact3 - ${jdk}") { - withMaven( - maven: mvnName, - jdk: "$jdk", - publisherStrategy: 'EXPLICIT', - globalMavenSettingsConfig: settingsName, - mavenOpts: mavenOpts, - mavenLocalRepo: localRepo) { - sh "mvn -f aggregates/jetty-all-compact3 -V -B -Pcompact3 clean install -T6" + stage("Build Compact3") { + agent { node { label 'linux' } } + options { timeout(time: 120, unit: 'MINUTES') } + steps { + mavenBuild("jdk8", "-Pcompact3 package") + warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] + } } } } } } + +def mavenBuild(jdk, cmdline) { + def mvnName = 'maven3.5' + def localRepo = "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}" // ".repository" // + def settingsName = 'oss-settings.xml' + def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true' + + withMaven( + maven: mvnName, + jdk: "$jdk", + publisherStrategy: 'EXPLICIT', + globalMavenSettingsConfig: settingsName, + mavenOpts: mavenOpts, + mavenLocalRepo: localRepo) { + // Some common Maven command line + provided command line + sh "mvn -V -B -T3 -e -Dmaven.test.failure.ignore=true -Djetty.testtracker.log=true $cmdline -Dunix.socket.tmp=" + env.JENKINS_HOME + } +} + // vim: et:ts=2:sw=2:ft=groovy \ No newline at end of file From ea315138abd35d86dcc99cb4b77d6674b0b7e49f Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 13 Nov 2018 07:24:29 -0600 Subject: [PATCH 2/2] Using new Declarative Jenkinsfile format + Ensuring that javadoc and compact3 builds will work in isolation to the other stages. Signed-off-by: Joakim Erdfelt --- Jenkinsfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 530b3a8deda..1792f665999 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,7 +57,7 @@ pipeline { agent { node { label 'linux' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - mavenBuild("jdk8", "javadoc:javadoc") + mavenBuild("jdk8", "install javadoc:javadoc -DskipTests") warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']] } } @@ -66,7 +66,7 @@ pipeline { agent { node { label 'linux' } } options { timeout(time: 120, unit: 'MINUTES') } steps { - mavenBuild("jdk8", "-Pcompact3 package") + mavenBuild("jdk8", "-Pcompact3 install -DskipTests") warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] } } @@ -75,7 +75,15 @@ pipeline { } } - +/** + * To other developers, if you are using this method above, please use the following syntax. + * + * mavenBuild("", " " + * + * @param jdk the jdk tool name (in jenkins) to use for this build + * @param cmdline the command line in " "`format. + * @return the Jenkinsfile step representing a maven build + */ def mavenBuild(jdk, cmdline) { def mvnName = 'maven3.5' def localRepo = "${env.JENKINS_HOME}/${env.EXECUTOR_NUMBER}" // ".repository" //