|
| 1 | +#!groovy |
| 2 | + |
| 3 | +pipeline { |
| 4 | + agent none |
| 5 | + // save some io during the build |
| 6 | + options { |
| 7 | + skipDefaultCheckout() |
| 8 | + durabilityHint('PERFORMANCE_OPTIMIZED') |
| 9 | + //buildDiscarder logRotator( numToKeepStr: '60' ) |
| 10 | + disableRestartFromStage() |
| 11 | + } |
| 12 | + stages { |
| 13 | + stage("Parallel Stage") { |
| 14 | + parallel { |
| 15 | + |
| 16 | + stage("Build / Test - JDK17") { |
| 17 | + agent { node { label 'ubuntu' } } |
| 18 | + steps { |
| 19 | + timeout(time: 210, unit: 'MINUTES') { |
| 20 | + checkout scm |
| 21 | + mavenBuild("jdk_17_latest", "-Djacoco.skip=true") |
| 22 | + script { |
| 23 | + properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr: env.BRANCH_NAME == 'master' ? '30' : '5'))]) |
| 24 | + if (env.BRANCH_NAME == 'master') { |
| 25 | + withEnv(["JAVA_HOME=${tool "jdk_17_latest"}", |
| 26 | + "PATH+MAVEN=${ tool "jdk_17_latest" }/bin:${tool "maven_3_latest"}/bin", |
| 27 | + "MAVEN_OPTS=-Xms4G -Xmx4G -Djava.awt.headless=true"]) { |
| 28 | + sh "mvn clean deploy -DdeployAtEnd=true -B" |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + stage("Build / Test - JDK21") { |
| 37 | + agent { node { label 'ubuntu' } } |
| 38 | + steps { |
| 39 | + timeout(time: 210, unit: 'MINUTES') { |
| 40 | + checkout scm |
| 41 | + // jacoco is definitely too slow |
| 42 | + mavenBuild("jdk_21_latest", "") // "-Pjacoco jacoco-aggregator:report-aggregate-all" |
| 43 | + // recordIssues id: "analysis-jdk17", name: "Static Analysis jdk17", aggregatingResults: true, enabledForFailure: true, |
| 44 | + // tools: [mavenConsole(), java(), checkStyle(), errorProne(), spotBugs(), javaDoc()], |
| 45 | + // skipPublishingChecks: true, skipBlames: true |
| 46 | + // recordCoverage id: "coverage-jdk21", name: "Coverage jdk21", tools: [[parser: 'JACOCO',pattern: 'target/site/jacoco-aggregate/jacoco.xml']], |
| 47 | + // sourceCodeRetention: 'MODIFIED', sourceDirectories: [[path: 'src/main/java']] |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +/** |
| 57 | + * To other developers, if you are using this method above, please use the following syntax. |
| 58 | + * |
| 59 | + * mavenBuild("<jdk>", "<profiles> <goals> <plugins> <properties>" |
| 60 | + * |
| 61 | + * @param jdk the jdk tool name (in jenkins) to use for this build |
| 62 | + * @param extraArgs extra command line args |
| 63 | + */ |
| 64 | +def mavenBuild(jdk, extraArgs) { |
| 65 | + script { |
| 66 | + try { |
| 67 | + withEnv(["JAVA_HOME=${tool "$jdk"}", |
| 68 | + "PATH+MAVEN=${ tool "$jdk" }/bin:${tool "maven_3_latest"}/bin", |
| 69 | + "MAVEN_OPTS=-Xms4G -Xmx4G -Djava.awt.headless=true"]) { |
| 70 | + sh "mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper -Dmaven=3.9.9" |
| 71 | + sh "./mvnw clean install -B -U -e -DskipTests -PversionlessMavenDist -V -DdistributionTargetDir=${env.WORKSPACE}/.apache-maven-master" |
| 72 | + // we use two steps so that we can cache artifacts downloaded from Maven Central repository |
| 73 | + // without installing any local artifacts to not pollute the cache |
| 74 | + sh "echo package Its" |
| 75 | + sh "./mvnw package -DskipTests -e -B -V -Prun-its -Dmaven.repo.local=${env.WORKSPACE}/.repository/cached" |
| 76 | + sh "echo run Its" |
| 77 | + sh "./mvnw install -Pci $extraArgs -Dmaven.home=${env.WORKSPACE}/.apache-maven-master -e -B -V -Prun-its -Dmaven.repo.local=${env.WORKSPACE}/.repository/local -Dmaven.repo.local.tail=${env.WORKSPACE}/.repository/cached" |
| 78 | + } |
| 79 | + } |
| 80 | + finally { |
| 81 | + junit testResults: '**/target/test-results-surefire/*.xml', allowEmptyResults: true |
| 82 | + } |
| 83 | + } |
| 84 | +} |
| 85 | +// vim: et:ts=2:sw=2:ft=groovy |
0 commit comments