| 
									
										
										
										
											2016-09-18 11:29:26 +08:00
										 |  |  | #!/usr/bin/env groovy | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2017-02-26 02:56:01 +08:00
										 |  |  |  * This Jenkinsfile is intended to run on https://ci.jenkins.io and may fail anywhere else. | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  |  * It makes assumptions about plugins being installed, labels mapping to nodes that can build what is needed, etc. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-24 04:54:04 +08:00
										 |  |  | def buildNumber = BUILD_NUMBER as int; if (buildNumber > 1) milestone(buildNumber - 1); milestone(buildNumber) // JENKINS-43353 / JENKINS-58625 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 04:15:12 +08:00
										 |  |  | def failFast = false | 
					
						
							| 
									
										
										
										
											2021-10-22 16:56:42 +08:00
										 |  |  | // Same memory sizing for both builds and ATH | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  | def javaOpts = [ | 
					
						
							|  |  |  |   'JAVA_OPTS=-Xmx1536m -Xms512m', | 
					
						
							|  |  |  |   'MAVEN_OPTS=-Xmx1536m -Xms512m', | 
					
						
							|  |  |  | ] | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-13 15:08:10 +08:00
										 |  |  | properties([ | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |   buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '3')), | 
					
						
							|  |  |  |   disableConcurrentBuilds(abortPrevious: true) | 
					
						
							| 
									
										
										
										
											2021-10-13 15:08:10 +08:00
										 |  |  | ]) | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 22:50:01 +08:00
										 |  |  | def buildTypes = ['Linux', 'Windows'] | 
					
						
							| 
									
										
										
										
											2018-12-12 23:41:04 +08:00
										 |  |  | def jdks = [8, 11] | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 04:15:12 +08:00
										 |  |  | def builds = [:] | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  | for (i = 0; i < buildTypes.size(); i++) { | 
					
						
							|  |  |  |   for (j = 0; j < jdks.size(); j++) { | 
					
						
							| 
									
										
										
										
											2017-01-04 04:15:12 +08:00
										 |  |  |     def buildType = buildTypes[i] | 
					
						
							| 
									
										
										
										
											2018-09-29 02:46:29 +08:00
										 |  |  |     def jdk = jdks[j] | 
					
						
							| 
									
										
										
										
											2021-12-21 22:50:01 +08:00
										 |  |  |     if (buildType == 'Windows' && jdk == 8) { | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |       continue // unnecessary use of hardware | 
					
						
							| 
									
										
										
										
											2021-12-21 22:50:01 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-29 02:46:29 +08:00
										 |  |  |     builds["${buildType}-jdk${jdk}"] = { | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |       // see https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#node-labels for information on what node types are available | 
					
						
							|  |  |  |       def agentContainerLabel = jdk == 8 ? 'maven' : 'maven-' + jdk | 
					
						
							|  |  |  |       if (buildType == 'Windows') { | 
					
						
							|  |  |  |         agentContainerLabel += '-windows' | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       node(agentContainerLabel) { | 
					
						
							|  |  |  |         // First stage is actually checking out the source. Since we're using Multibranch | 
					
						
							|  |  |  |         // currently, we can use "checkout scm". | 
					
						
							|  |  |  |         stage('Checkout') { | 
					
						
							|  |  |  |           checkout scm | 
					
						
							| 
									
										
										
										
											2021-12-21 22:50:01 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-01-28 22:56:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |         def changelistF = "${pwd tmp: true}/changelist" | 
					
						
							|  |  |  |         def m2repo = "${pwd tmp: true}/m2repo" | 
					
						
							| 
									
										
										
										
											2018-05-03 22:13:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |         // Now run the actual build. | 
					
						
							|  |  |  |         stage("${buildType} Build / Test") { | 
					
						
							|  |  |  |           timeout(time: 5, unit: 'HOURS') { | 
					
						
							|  |  |  |             realtimeJUnit(healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml,war/junit.xml') { | 
					
						
							|  |  |  |               def mavenOptions = [ | 
					
						
							|  |  |  |                 '-Pdebug', | 
					
						
							|  |  |  |                 '--update-snapshots', | 
					
						
							|  |  |  |                 "-Dmaven.repo.local=$m2repo", | 
					
						
							|  |  |  |                 '-Dmaven.test.failure.ignore', | 
					
						
							|  |  |  |                 '-Dspotbugs.failOnError=false', | 
					
						
							|  |  |  |                 '-Dcheckstyle.failOnViolation=false', | 
					
						
							|  |  |  |                 '-Dset.changelist', | 
					
						
							|  |  |  |                 'help:evaluate', | 
					
						
							|  |  |  |                 '-Dexpression=changelist', | 
					
						
							|  |  |  |                 "-Doutput=$changelistF", | 
					
						
							|  |  |  |                 'clean', | 
					
						
							|  |  |  |                 'install', | 
					
						
							|  |  |  |               ] | 
					
						
							|  |  |  |               infra.runMaven(mavenOptions, jdk.toString(), javaOpts, null, true) | 
					
						
							|  |  |  |               if (isUnix()) { | 
					
						
							|  |  |  |                 sh 'git add . && git diff --exit-code HEAD' | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-01-04 04:15:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |         // Once we've built, archive the artifacts and the test results. | 
					
						
							|  |  |  |         stage("${buildType} Publishing") { | 
					
						
							|  |  |  |           archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/surefire-reports/*.dumpstream' | 
					
						
							|  |  |  |           if (!fileExists('core/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml')) { | 
					
						
							|  |  |  |             error 'JUnit 4 tests are no longer being run for the core package' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           if (!fileExists('test/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml')) { | 
					
						
							|  |  |  |             error 'JUnit 4 tests are no longer being run for the test package' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           // cli has been migrated to JUnit 5 | 
					
						
							|  |  |  |           if (failFast && currentBuild.result == 'UNSTABLE') { | 
					
						
							|  |  |  |             error 'There were test failures; halting early' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           if (buildType == 'Linux' && jdk == jdks[0]) { | 
					
						
							|  |  |  |             def folders = env.JOB_NAME.split('/') | 
					
						
							|  |  |  |             if (folders.length > 1) { | 
					
						
							|  |  |  |               discoverGitReferenceBuild(scm: folders[1]) | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-10-06 01:11:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |             echo "Recording static analysis results for '${buildType}'" | 
					
						
							|  |  |  |             recordIssues( | 
					
						
							|  |  |  |                 enabledForFailure: true, | 
					
						
							|  |  |  |                 tools: [java(), javaDoc()], | 
					
						
							|  |  |  |                 filters: [excludeFile('.*Assert.java')], | 
					
						
							|  |  |  |                 sourceCodeEncoding: 'UTF-8', | 
					
						
							|  |  |  |                 skipBlames: true, | 
					
						
							|  |  |  |                 trendChartType: 'TOOLS_ONLY' | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             recordIssues([tool: spotBugs(pattern: '**/target/spotbugsXml.xml'), | 
					
						
							|  |  |  |               sourceCodeEncoding: 'UTF-8', | 
					
						
							|  |  |  |               skipBlames: true, | 
					
						
							|  |  |  |               trendChartType: 'TOOLS_ONLY', | 
					
						
							|  |  |  |               qualityGates: [ | 
					
						
							|  |  |  |                 [threshold: 1, type: 'NEW', unstable: true], | 
					
						
							|  |  |  |               ]]) | 
					
						
							|  |  |  |             recordIssues([tool: checkStyle(pattern: '**/target/checkstyle-result.xml'), | 
					
						
							|  |  |  |               sourceCodeEncoding: 'UTF-8', | 
					
						
							|  |  |  |               skipBlames: true, | 
					
						
							|  |  |  |               trendChartType: 'TOOLS_ONLY', | 
					
						
							|  |  |  |               qualityGates: [ | 
					
						
							|  |  |  |                 [threshold: 1, type: 'TOTAL', unstable: true], | 
					
						
							|  |  |  |               ]]) | 
					
						
							|  |  |  |             if (failFast && currentBuild.result == 'UNSTABLE') { | 
					
						
							|  |  |  |               error 'Static analysis quality gates not passed; halting early' | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-10-06 01:11:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |             def changelist = readFile(changelistF) | 
					
						
							|  |  |  |             dir(m2repo) { | 
					
						
							|  |  |  |               archiveArtifacts( | 
					
						
							|  |  |  |                   artifacts: "**/*$changelist/*$changelist*", | 
					
						
							|  |  |  |                   excludes: '**/*.lastUpdated,**/jenkins-test*/', | 
					
						
							|  |  |  |                   allowEmptyArchive: true, // in case we forgot to reincrementalify | 
					
						
							|  |  |  |                   fingerprint: true | 
					
						
							|  |  |  |                   ) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2016-01-21 07:52:06 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-21 00:42:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 18:24:14 +08:00
										 |  |  | builds.ath = { | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |   node('docker-highmem') { | 
					
						
							|  |  |  |     // Just to be safe | 
					
						
							|  |  |  |     deleteDir() | 
					
						
							|  |  |  |     def fileUri | 
					
						
							|  |  |  |     def metadataPath | 
					
						
							|  |  |  |     dir('sources') { | 
					
						
							|  |  |  |       checkout scm | 
					
						
							|  |  |  |       def mavenOptions = [ | 
					
						
							|  |  |  |         '-Pquick-build', | 
					
						
							|  |  |  |         '-Dmaven.repo.local=$WORKSPACE_TMP/m2repo', | 
					
						
							|  |  |  |         '-am', | 
					
						
							|  |  |  |         '-pl', | 
					
						
							|  |  |  |         'war', | 
					
						
							|  |  |  |         'package', | 
					
						
							|  |  |  |       ] | 
					
						
							|  |  |  |       infra.runMaven(mavenOptions, '11', javaOpts, null, true) | 
					
						
							|  |  |  |       dir('war/target') { | 
					
						
							|  |  |  |         fileUri = 'file://' + pwd() + '/jenkins.war' | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       metadataPath = pwd() + '/essentials.yml' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     dir('ath') { | 
					
						
							|  |  |  |       runATH jenkins: fileUri, metadataFile: metadataPath | 
					
						
							| 
									
										
										
										
											2018-03-13 17:26:05 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-25 08:35:53 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-10-31 23:03:59 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-13 17:26:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 18:24:14 +08:00
										 |  |  | builds.failFast = failFast | 
					
						
							|  |  |  | parallel builds | 
					
						
							| 
									
										
										
										
											2018-05-03 22:13:39 +08:00
										 |  |  | infra.maybePublishIncrementals() |