forked from jenkinsci/bom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
134 lines (124 loc) · 4.92 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
properties([
disableConcurrentBuilds(abortPrevious: true),
buildDiscarder(logRotator(numToKeepStr: '7')),
pipelineTriggers([cron('18 03 * * 6')])
])
if (BRANCH_NAME == 'master' && currentBuild.buildCauses*._class == ['jenkins.branch.BranchEventCause']) {
currentBuild.result = 'NOT_BUILT'
error 'No longer running builds on response to master branch pushes. If you wish to cut a release, use “Re-run checks” from this failing check in https://github.com/jenkinsci/bom/commits/master'
}
def mavenEnv(Map params = [:], Closure body) {
def attempt = 0
def attempts = 6
retry(count: attempts, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) {
echo 'Attempt ' + ++attempt + ' of ' + attempts
// no Dockerized tests; https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#container-agents
node(params['nodePool'] ? 'maven-bom': 'maven-' + params['jdk']) {
timeout(120) {
withChecks(name: 'Tests', includeStage: true) {
infra.withArtifactCachingProxy {
withEnv([
'JAVA_HOME=/opt/jdk-' + params['jdk'],
"MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo"
]) {
body()
}
}
if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) {
// TODO JENKINS-27092 throw up UNSTABLE status in this case
error 'Some test failures, not going to continue'
}
}
}
}
}
}
@NonCPS
def parsePlugins(plugins) {
def pluginsByRepository = [:]
plugins.each { plugin ->
def splits = plugin.split('\t')
pluginsByRepository[splits[0].split('/')[1]] = splits[1].split(',')
}
pluginsByRepository
}
def pluginsByRepository
def lines
def fullTestMarkerFile
def weeklyTestMarkerFile
stage('prep') {
mavenEnv(jdk: 21) {
checkout scm
withEnv(['SAMPLE_PLUGIN_OPTS=-Dset.changelist']) {
withCredentials([
usernamePassword(credentialsId: 'app-ci.jenkins.io', usernameVariable: 'GITHUB_APP', passwordVariable: 'GITHUB_OAUTH')
]) {
sh '''
mvn -v
echo "Starting artifact caching proxy pre-heat"
mvn -ntp dependency:go-offline
echo "Finished artifact caching proxy pre-heat"
bash prep.sh
'''
}
}
fullTestMarkerFile = fileExists 'full-test'
weeklyTestMarkerFile = fileExists 'weekly-test'
dir('target') {
def plugins = readFile('plugins.txt').split('\n')
pluginsByRepository = parsePlugins(plugins)
lines = readFile('lines.txt').split('\n')
withCredentials([string(credentialsId: 'launchable-jenkins-bom', variable: 'LAUNCHABLE_TOKEN')]) {
lines.each { line ->
def commitHashes = readFile "commit-hashes-${line}.txt"
sh "launchable verify && launchable record build --name ${env.BUILD_TAG}-${line} --no-commit-collection " + commitHashes
def sessionFile = "launchable-session-${line}.txt"
def jdk = line == 'weekly' ? 21 : 17
sh "launchable record session --build ${env.BUILD_TAG}-${line} --flavor platform=linux --flavor jdk=${jdk} >${sessionFile}"
stash name: sessionFile, includes: sessionFile
}
}
}
lines.each { line ->
stash name: line, includes: "pct.sh,excludes.txt,target/pct.jar,target/megawar-${line}.war"
}
infra.prepareToPublishIncrementals()
}
}
if (BRANCH_NAME == 'master' || fullTestMarkerFile || weeklyTestMarkerFile || env.CHANGE_ID && (pullRequest.labels.contains('full-test') || pullRequest.labels.contains('weekly-test'))) {
branches = [failFast: false]
lines.each {line ->
if (line != 'weekly' && (weeklyTestMarkerFile || env.CHANGE_ID && pullRequest.labels.contains('weekly-test'))) {
return
}
pluginsByRepository.each { repository, plugins ->
branches["pct-$repository-$line"] = {
def jdk = line == 'weekly' ? 21 : 17
mavenEnv(jdk: jdk, nodePool: true) {
unstash line
withEnv([
"PLUGINS=${plugins.join(',')}",
"LINE=$line",
'EXTRA_MAVEN_PROPERTIES=maven.test.failure.ignore=true:surefire.rerunFailingTestsCount=1'
]) {
sh '''
mvn -v
bash pct.sh
'''
}
withCredentials([string(credentialsId: 'launchable-jenkins-bom', variable: 'LAUNCHABLE_TOKEN')]) {
def sessionFile = "launchable-session-${line}.txt"
unstash sessionFile
def session = readFile(sessionFile).trim()
sh "launchable verify && launchable record tests --session ${session} --group ${repository} maven './**/target/surefire-reports' './**/target/failsafe-reports'"
}
}
}
}
}
parallel branches
}
if (fullTestMarkerFile) {
error 'Remember to `git rm full-test` before taking out of draft'
}
infra.maybePublishIncrementals()