forked from jenkinsci/jenkinsfile-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
107 lines (89 loc) · 3.44 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
/* Only keep the 10 most recent builds. */
properties([[$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']]])
// TODO: Move it to Jenkins Pipeline Library
def branchName = currentBuild.projectName
def buildNumber = currentBuild.number
/* These platforms correspond to labels in ci.jenkins.io, see:
* https://github.com/jenkins-infra/documentation/blob/master/ci.adoc
*/
List platforms = ['linux']
Map branches = [:]
for (int i = 0; i < platforms.size(); ++i) {
String label = platforms[i]
branches[label] = {
node(label + " && docker") {
timestamps {
ws("platform_${label}_${branchName}_${buildNumber}") {
stage('Checkout') {
checkout scm
}
stage('Build') {
timeout(60) {
infra.runMaven(['clean', 'install', '-Dset.changelist', '-Dmaven.test.failure.ignore=true', '-Denvironment=test', '-Ppackage-app,package-vanilla,jacoco,run-its'])
}
}
stage('Archive') {
/* Archive the test results */
junit '**/target/surefire-reports/TEST-*.xml'
if (label == 'linux') {
infra.prepareToPublishIncrementals()
recordIssues(
enabledForFailure: true, aggregatingResults: true,
tools: [java(), spotBugs(pattern: '**/target/spotbugsXml.xml')]
)
publishCoverage adapters: [jacocoAdapter(mergeToOneReport: true, path: 'vanilla-package/target/site/jacoco-aggregate/*.xml')]
}
}
}
}
}
}
}
/* Execute our platforms in parallel */
parallel(branches)
stage('Verify Custom WAR Packager demo')
Map demos = [:]
demos['cwp'] = {
node('docker') {
timestamps {
ws("cwp_${branchName}_${buildNumber}") {
checkout scm
stage('CWP') {
dir('demo/cwp') {
sh "make clean buildInDocker run"
}
}
}
}
}
}
parallel(demos)
node('docker') {
ws("container_${branchName}_${buildNumber}") {
infra.withDockerCredentials {
def image
def imageName = "${env.DOCKERHUB_ORGANISATION}/jenkinsfile-runner"
def imageTag
stage('Build container') {
timestamps {
def scmVars = checkout scm
def shortCommit = scmVars.GIT_COMMIT
imageTag = branchName.equals("master") ? "latest" : branchName
echo "Creating the container ${imageName}:${imageTag}"
sh "docker build -t ${imageName}:${imageTag} --no-cache --rm -f packaging/docker/unix/adoptopenjdk-8-hotspot/Dockerfile ."
}
}
// TODO(oleg-nenashev): Reenable once CI is stable
// if (branchName.startsWith('master')) {
// stage('Publish container') {
// timestamps {
// image.push();
// }
// }
// }
}
}
}
// TODO: Run integration tests
infra.maybePublishIncrementals()