Skip to content

Commit cc92a25

Browse files
committed
fix: use plugin sample for caching generation
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
1 parent 3b400e5 commit cc92a25

File tree

1 file changed

+30
-163
lines changed

1 file changed

+30
-163
lines changed

Jenkinsfile

Lines changed: 30 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -4,170 +4,37 @@ properties([
44
// pipelineTriggers([cron('54 20 * * 6')])
55
])
66

7-
if (BRANCH_NAME == 'master' && currentBuild.buildCauses*._class == ['jenkins.branch.BranchEventCause']) {
8-
currentBuild.result = 'NOT_BUILT'
9-
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'
10-
}
11-
12-
13-
def mavenEnv(Map params = [:], Closure body) {
14-
def attempt = 0
15-
def attempts = 6
16-
retry(count: attempts, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) {
17-
echo 'Attempt ' + ++attempt + ' of ' + attempts
18-
// no Dockerized tests; https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#container-agents
19-
// node('maven-bom-cacher') {
20-
// timeout(120) {
21-
// withChecks(name: 'Tests', includeStage: true) {
22-
infra.withArtifactCachingProxy {
23-
withEnv([
24-
'JAVA_HOME=/opt/jdk-' + params['jdk'],
25-
"MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo",
26-
"MVN_LOCAL_REPO=${WORKSPACE_TMP}/m2repo",
27-
]) {
28-
body()
29-
}
30-
}
31-
// if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) {
32-
// // TODO JENKINS-27092 throw up UNSTABLE status in this case
33-
// error 'Some test failures, not going to continue'
34-
// }
35-
// }
36-
// }
37-
}
38-
// }
39-
}
40-
41-
@NonCPS
42-
def parsePlugins(plugins) {
43-
def pluginsByRepository = [:]
44-
plugins.each { plugin ->
45-
def splits = plugin.split('\t')
46-
pluginsByRepository[splits[0].split('/')[1]] = splits[1].split(',')
47-
}
48-
pluginsByRepository
49-
}
50-
51-
def pluginsByRepository
52-
def lines
53-
def fullTestMarkerFile
54-
def weeklyTestMarkerFile
55-
567
node('maven-bom-cacher') {
57-
stage('prep') {
58-
mavenEnv(jdk: 21) {
59-
checkout scm
60-
withEnv(['SAMPLE_PLUGIN_OPTS=-Dset.changelist']) {
61-
withCredentials([
62-
usernamePassword(credentialsId: 'app-ci.jenkins.io', usernameVariable: 'GITHUB_APP', passwordVariable: 'GITHUB_OAUTH')
63-
]) {
64-
// Load Maven Repo Cache if available
65-
sh '''
66-
mkdir -p "${MVN_LOCAL_REPO}"
67-
if test -f /cache-rw/maven-bom-local-repo.tar.gz;
68-
then
69-
time tar xzf /cache-rw/maven-bom-local-repo.tar.gz -C "${MVN_LOCAL_REPO}"
70-
fi
71-
'''
72-
73-
sh '''
74-
mvn dependency:go-offline -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo
75-
'''
76-
77-
sh '''
78-
mvn -v
79-
bash prep.sh
80-
'''
81-
}
82-
}
83-
fullTestMarkerFile = fileExists 'full-test'
84-
weeklyTestMarkerFile = fileExists 'weekly-test'
85-
dir('target') {
86-
sh '''
87-
mv plugins.txt plugins.txt.orig
88-
89-
head -n50 plugins.txt.orig > plugins.txt
90-
'''
91-
92-
sh '''
93-
cat lines.txt
94-
cat plugins.txt
95-
'''
96-
97-
def plugins = readFile('plugins.txt').split('\n')
98-
pluginsByRepository = parsePlugins(plugins)
99-
100-
lines = readFile('lines.txt').split('\n')
101-
// withCredentials([string(credentialsId: 'launchable-jenkins-bom', variable: 'LAUNCHABLE_TOKEN')]) {
102-
// lines.each { line ->
103-
// def commitHashes = readFile "commit-hashes-${line}.txt"
104-
// sh "launchable verify && launchable record build --name ${env.BUILD_TAG}-${line} --no-commit-collection " + commitHashes
105-
106-
// def sessionFile = "launchable-session-${line}.txt"
107-
// def jdk = line == 'weekly' ? 21 : 17
108-
// sh "launchable record session --build ${env.BUILD_TAG}-${line} --flavor platform=linux --flavor jdk=${jdk} >${sessionFile}"
109-
// stash name: sessionFile, includes: sessionFile
110-
// }
111-
// }
112-
}
113-
lines.each { line ->
114-
stash name: line, includes: "pct.sh,excludes.txt,target/pct.jar,target/megawar-${line}.war"
115-
}
116-
// infra.prepareToPublishIncrementals()
8+
infra.withArtifactCachingProxy {
9+
withEnv([
10+
'JAVA_HOME=/opt/jdk-21',
11+
"MVN_LOCAL_REPO=${WORKSPACE_TMP}/m2repo",
12+
]) {
13+
sh '''
14+
mkdir -p "${MVN_LOCAL_REPO}"
15+
if test -f /cache-rw/maven-bom-local-repo.tar.gz;
16+
then
17+
pushd "${MVN_LOCAL_REPO}"
18+
time cp /cache-rw/maven-bom-local-repo.tar.gz ../
19+
time tar xzf ../maven-bom-local-repo.tar.gz
20+
rm -f ../maven-bom-local-repo.tar.gz
21+
popd
22+
fi
23+
'''
24+
25+
sh '''
26+
mvn -pl sample-plugin dependency:go-offline -Dmaven.repo.local=${MVN_LOCAL_REPO}
27+
'''
28+
29+
sh '''
30+
pushd "${MVN_LOCAL_REPO}"
31+
df -h .
32+
du -sh .
33+
time tar czf ../maven-bom-local-repo.tar.gz ./
34+
time cp ../maven-bom-local-repo.tar.gz /cache-rw/maven-bom-local-repo.tar.gz
35+
du -sh /cache-rw/*
36+
popd
37+
'''
11738
}
11839
}
119-
120-
// if (BRANCH_NAME == 'master' || fullTestMarkerFile || weeklyTestMarkerFile || env.CHANGE_ID && (pullRequest.labels.contains('full-test') || pullRequest.labels.contains('weekly-test'))) {
121-
// branches = [failFast: false]
122-
lines.each {line ->
123-
// if (line != 'weekly' && (weeklyTestMarkerFile || env.CHANGE_ID && pullRequest.labels.contains('weekly-test'))) {
124-
// return
125-
// }
126-
pluginsByRepository.each { repository, plugins ->
127-
stage("pct-$repository-$line") {
128-
// branches["pct-$repository-$line"] = {
129-
def jdk = line == 'weekly' ? 21 : 17
130-
mavenEnv(jdk: jdk, nodePool: true) {
131-
unstash line
132-
withEnv([
133-
"PLUGINS=${plugins.join(',')}",
134-
"LINE=$line",
135-
'EXTRA_MAVEN_PROPERTIES=maven.test.failure.ignore=true:surefire.rerunFailingTestsCount=1'
136-
]) {
137-
sh '''
138-
mvn -v
139-
du -sh "${MVN_LOCAL_REPO}"
140-
bash pct.sh
141-
du -sh "${MVN_LOCAL_REPO}"
142-
'''
143-
}
144-
// withCredentials([string(credentialsId: 'launchable-jenkins-bom', variable: 'LAUNCHABLE_TOKEN')]) {
145-
// def sessionFile = "launchable-session-${line}.txt"
146-
// unstash sessionFile
147-
// def session = readFile(sessionFile).trim()
148-
// sh "launchable verify && launchable record tests --session ${session} --group ${repository} maven './**/target/surefire-reports' './**/target/failsafe-reports'"
149-
// }
150-
}
151-
// }
152-
}
153-
}
154-
}
155-
156-
sh '''
157-
cd "${MVN_LOCAL_REPO}"
158-
df -h .
159-
du -sh .
160-
time tar czf ../maven-bom-local-repo.tar.gz ./
161-
du -sh /cache-rw/*
162-
time cp ../maven-bom-local-repo.tar.gz /cache-rw/maven-bom-local-repo.tar.gz
163-
du -sh /cache-rw/*
164-
'''
16540
}
166-
// parallel branches
167-
// }
168-
169-
// if (fullTestMarkerFile) {
170-
// error 'Remember to `git rm full-test` before taking out of draft'
171-
// }
172-
173-
// infra.maybePublishIncrementals()

0 commit comments

Comments
 (0)