-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Jenkinsfile
80 lines (78 loc) · 3.12 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
properties([
disableConcurrentBuilds(abortPrevious: true),
durabilityHint('PERFORMANCE_OPTIMIZED'),
buildDiscarder(logRotator(numToKeepStr: '5')),
])
def splits
stage('Determine splits') {
node('maven-11') {
checkout scm
splits = splitTests parallelism: count(2), generateInclusions: true, estimateTestsFromFiles: true
}
}
stage('Tests') {
def branches = [:]
branches['failFast'] = true
for (int i = 0; i < splits.size(); i++) {
def num = i
def split = splits[num]
def index = num + 1
branches["kind-${index}"] = {
node('docker') {
timeout(90) {
checkout scm
try {
writeFile file: (split.includes ? "$WORKSPACE_TMP/includes.txt" : "$WORKSPACE_TMP/excludes.txt"), text: split.list.join("\n")
writeFile file: (split.includes ? "$WORKSPACE_TMP/excludes.txt" : "$WORKSPACE_TMP/includes.txt"), text: ''
sh './kind.sh -Penable-jacoco -Dsurefire.includesFile="$WORKSPACE_TMP/includes.txt" -Dsurefire.excludesFile="$WORKSPACE_TMP/excludes.txt"'
junit 'target/surefire-reports/*.xml'
withEnv(['NUM=' + num]) {
sh '''
for f in $(find . -name jacoco.exec)
do
mv "$f" "$(echo "$f" | sed s/jacoco./jacoco-$NUM./)"
done
'''
}
if (num == 0) {
stash name: 'classes', includes: '**/target/classes/**'
}
stash name: 'coverage-exec-' + num, allowEmpty: true, includes: '**/target/jacoco*.exec'
} finally {
dir(env.WORKSPACE_TMP) {
if (fileExists('kindlogs/docker-info.txt')) {
archiveArtifacts 'kindlogs/'
}
}
}
}
}
}
}
branches['jdk11'] = {
retry(count: 3, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) {
node('maven-11') {
timeout(60) {
checkout scm
sh 'mvn -B -ntp -Dset.changelist -Dmaven.test.failure.ignore clean install'
infra.prepareToPublishIncrementals()
junit 'target/surefire-reports/*.xml'
}
}
}
}
parallel branches
stage('aggregate coverage') {
node('maven-17') {
checkout scm
unstash 'classes'
for (int i = 0; i < splits.size(); i++) {
unstash 'coverage-exec-' + i
}
sh 'mvn -B -ntp -P merge-jacoco-reports validate'
recordCoverage(tools: [[parser: 'JACOCO', pattern: '**/jacoco/jacoco.xml']], sourceCodeRetention: 'MODIFIED')
}
}
}
// Stage part of the library
infra.maybePublishIncrementals()