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.
|
|
|
|
*/
|
|
|
|
|
2017-01-04 04:15:12 +08:00
|
|
|
def failFast = false
|
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']
|
2022-12-09 05:16:20 +08:00
|
|
|
def jdks = [11, 17, 19]
|
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]
|
2022-12-09 05:16:20 +08:00
|
|
|
if (buildType == 'Windows' && jdk != 17) {
|
|
|
|
continue // unnecessary use of hardware
|
|
|
|
}
|
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
|
2022-06-25 00:56:33 +08:00
|
|
|
def agentContainerLabel = 'maven-' + jdk
|
2021-12-25 08:35:53 +08:00
|
|
|
if (buildType == 'Windows') {
|
|
|
|
agentContainerLabel += '-windows'
|
|
|
|
}
|
2022-10-11 10:57:17 +08:00
|
|
|
retry(conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()], count: 2) {
|
|
|
|
node(agentContainerLabel) {
|
|
|
|
// First stage is actually checking out the source. Since we're using Multibranch
|
|
|
|
// currently, we can use "checkout scm".
|
|
|
|
stage('Checkout') {
|
|
|
|
infra.checkoutSCM()
|
|
|
|
}
|
2016-01-28 22:56:22 +08:00
|
|
|
|
2022-10-11 10:57:17 +08:00
|
|
|
def changelistF = "${pwd tmp: true}/changelist"
|
|
|
|
def m2repo = "${pwd tmp: true}/m2repo"
|
2018-05-03 22:13:39 +08:00
|
|
|
|
2022-10-11 10:57:17 +08:00
|
|
|
// Now run the actual build.
|
|
|
|
stage("${buildType} Build / Test") {
|
|
|
|
timeout(time: 6, unit: 'HOURS') {
|
|
|
|
realtimeJUnit(healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml') {
|
|
|
|
def mavenOptions = [
|
|
|
|
'-Pdebug',
|
|
|
|
'-Penable-jacoco',
|
|
|
|
'--update-snapshots',
|
|
|
|
"-Dmaven.repo.local=$m2repo",
|
|
|
|
'-Dmaven.test.failure.ignore',
|
|
|
|
'-DforkCount=2',
|
|
|
|
'-Dspotbugs.failOnError=false',
|
|
|
|
'-Dcheckstyle.failOnViolation=false',
|
|
|
|
'-Dset.changelist',
|
|
|
|
'help:evaluate',
|
|
|
|
'-Dexpression=changelist',
|
|
|
|
"-Doutput=$changelistF",
|
|
|
|
'clean',
|
|
|
|
'install',
|
|
|
|
]
|
2022-06-11 01:30:20 +08:00
|
|
|
infra.runMaven(mavenOptions, jdk)
|
|
|
|
if (isUnix()) {
|
|
|
|
sh 'git add . && git diff --exit-code HEAD'
|
|
|
|
}
|
2021-12-25 08:35:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-04 04:15:12 +08:00
|
|
|
|
2022-10-11 10:57:17 +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'
|
2021-12-25 08:35:53 +08:00
|
|
|
}
|
2022-10-11 10:57:17 +08:00
|
|
|
// cli and war have 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])
|
|
|
|
}
|
|
|
|
publishCoverage calculateDiffForChangeRequests: true, adapters: [jacocoAdapter('coverage/target/site/jacoco-aggregate/jacoco.xml')]
|
2021-10-06 01:11:09 +08:00
|
|
|
|
2022-10-11 10:57:17 +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'),
|
2021-12-25 08:35:53 +08:00
|
|
|
sourceCodeEncoding: 'UTF-8',
|
|
|
|
skipBlames: true,
|
2022-10-11 10:57:17 +08:00
|
|
|
trendChartType: 'TOOLS_ONLY',
|
|
|
|
qualityGates: [
|
|
|
|
[threshold: 1, type: 'TOTAL', unstable: true],
|
|
|
|
]])
|
|
|
|
recordIssues([tool: esLint(pattern: '**/target/eslint-warnings.xml'),
|
|
|
|
sourceCodeEncoding: 'UTF-8',
|
|
|
|
skipBlames: true,
|
|
|
|
trendChartType: 'TOOLS_ONLY',
|
|
|
|
qualityGates: [
|
|
|
|
[threshold: 1, type: 'TOTAL', unstable: true],
|
|
|
|
]])
|
2022-07-13 23:02:07 +08:00
|
|
|
recordIssues([tool: styleLint(pattern: '**/target/stylelint-warnings.xml'),
|
2022-10-11 10:57:17 +08:00
|
|
|
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
|
|
|
|
2022-10-11 10:57:17 +08:00
|
|
|
def changelist = readFile(changelistF)
|
|
|
|
dir(m2repo) {
|
|
|
|
archiveArtifacts(
|
|
|
|
artifacts: "**/*$changelist/*$changelist*",
|
|
|
|
excludes: '**/*.lastUpdated,**/jenkins-coverage*/,**/jenkins-test*/',
|
|
|
|
allowEmptyArchive: true, // in case we forgot to reincrementalify
|
|
|
|
fingerprint: true
|
|
|
|
)
|
|
|
|
}
|
2021-12-25 08:35:53 +08:00
|
|
|
}
|
|
|
|
}
|
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 = {
|
2022-10-11 10:57:17 +08:00
|
|
|
retry(conditions: [agent(), nonresumable()], count: 2) {
|
|
|
|
node('docker-highmem') {
|
|
|
|
// Just to be safe
|
|
|
|
deleteDir()
|
2022-11-22 05:38:50 +08:00
|
|
|
checkout scm
|
|
|
|
sh 'bash ath.sh'
|
|
|
|
junit testResults: 'target/ath-reports/TEST-*.xml', testDataPublishers: [[$class: 'AttachmentPublisher']]
|
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()
|