-
Notifications
You must be signed in to change notification settings - Fork 173
/
Jenkinsfile-extended
203 lines (196 loc) · 6.66 KB
/
Jenkinsfile-extended
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!groovy
// This "extended pipeline" runs longer tests:
// * builds a tarball as usual
// * uses that tarball for
// + running Unix Debug checks
// + building MinGW Windows zipballs
// + running Embedded checks
// + running Coverity and Sonarscanner analysis
//
// The GIT checkout must use the remote branch name as the checkout local
// branch name so that tarball names contain the branch name.
// In "Additional Behaviours", enable "Checkout to specific local branch"
// and leave "Branch name" empty.
// Not needed for multi-branch pipelines which already BRANCH_NAME in the environment.
def gitRepoURL = ""
def gitBranch = ""
def tarballgz
def tarballbz2
def statusHasChanged = false
pipeline {
agent none
// Trigger the build
triggers {
// Poll GitHub explicitly on per night, in case webhooks aren't used
pollSCM('0 3 * * *')
}
stages {
stage('Tarball') {
steps {
node('autotools') {
checkout scm
script {
gitRepoURL = sh (script: 'git config --get remote.origin.url', returnStdout: true).trim()
gitBranch = sh (script: 'if test "$BRANCH_NAME"; then echo $BRANCH_NAME; else git rev-parse --abbrev-ref HEAD; fi', returnStdout: true).trim()
}
sh 'contrib/ci.inria.fr/job-0-tarball.sh '+gitBranch
script {
tarballgz = sh (script: 'ls *.gz', returnStdout: true).trim()
tarballbz2 = sh (script: 'ls *.bz2', returnStdout: true).trim()
}
stash includes: tarballgz, name: 'tarballgz'
sh 'tar zcvf android.tar.gz contrib/android'
stash includes: "android.tar.gz", name: 'tar-android'
dir('contrib/ci.inria.fr') {
stash includes: "job-3-debug.sh", name: 'script-unix-debug'
stash includes: "job-3-embedded.sh", name: 'script-embedded'
stash includes: "job-3-coverity.sh", name: 'script-coverity'
stash includes: "job-3-sonarscanner.sh", name: 'script-sonarscanner'
stash includes: "job-3-mingw.*", name: 'scripts-mingw'
stash includes: "job-3-cygwin.*", name: 'scripts-cygwin'
stash includes: "job-3-android.sh", name: 'script-android'
}
archiveArtifacts artifacts: tarballgz+","+tarballbz2+",doc/doxygen-doc/hwloc-a4.pdf", fingerprint: true, onlyIfSuccessful: true
deleteDir()
}
}
}
stage('Check') {
steps {
script {
listOfNodeNames = []
if (env.NO_UNIX != 'true') {
listOfNodeNames = nodesByLabel('unix')
}
if (env.NO_MINGW != 'true') {
listOfNodeNames.push('MinGW')
}
if (env.NO_COVERITY != 'true') {
listOfNodeNames.push('Coverity')
}
if (env.NO_SONARQUBE != 'true') {
listOfNodeNames.push('SonarQube Scanner')
}
if (env.NO_EMBEDDED != 'true') {
listOfNodeNames.push('Embedded')
}
if (env.NO_CYGWIN != 'true') {
listOfNodeNames.push('cygwin')
}
if(env.NO_ANDROID != 'true') {
listOfNodeNames.push('AndroidStudio')
}
def p = listOfNodeNames.collectEntries {
[ (it): {
if (it == 'MinGW') {
node('mingw') {
dir('check-mingw') {
unstash 'tarballgz'
unstash 'scripts-mingw'
bat 'job-3-mingw.bat '+tarballgz
archiveArtifacts artifacts: "*.zip", fingerprint: true, onlyIfSuccessful: true
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else if (it == 'cygwin') {
node('cygwin') {
dir('check-cygwin') {
unstash 'tarballgz'
unstash 'scripts-cygwin'
bat './job-3-cygwin.bat '+tarballgz
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else if (it == 'Coverity') {
node('coverity') {
dir('check-coverity') {
unstash 'tarballgz'
unstash 'script-coverity'
sh 'chmod 755 job-3-coverity.sh && ./job-3-coverity.sh '+gitRepoURL+' '+gitBranch+' '+tarballgz
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else if (it == 'SonarQube Scanner') {
node('sonarscanner') {
dir('check-sonarscanner') {
unstash 'tarballgz'
unstash 'script-sonarscanner'
sh 'chmod 755 job-3-sonarscanner.sh && ./job-3-sonarscanner.sh '+gitRepoURL+' '+gitBranch+' '+tarballgz
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else if (it == 'Embedded') {
node('autotools') {
dir('check-embedded') {
unstash 'tarballgz'
unstash 'script-embedded'
sh 'chmod 755 job-3-embedded.sh && ./job-3-embedded.sh '+tarballgz
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else if (it == 'AndroidStudio') {
node('android') {
dir('check-android') {
unstash 'script-android'
unstash 'tar-android'
unstash 'tarballgz'
sh 'chmod 755 job-3-android.sh && ./job-3-android.sh '+tarballgz
archiveArtifacts artifacts: "lstopo-android/*.apk", fingerprint: true, onlyIfSuccessful: true
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
} else {
node(it) {
dir('check-unix-debug') {
unstash 'tarballgz'
unstash 'script-unix-debug'
sh 'chmod 755 job-3-debug.sh && ./job-3-debug.sh '+tarballgz
if (env.KEEP_WORKING_DIRECTORY != 'true')
deleteDir()
}
}
}
}]}
parallel p;
}
}
}
}
post {
// hooks are called in order: always, changed, aborted, failure, success, unstable
changed {
echo "Build status has changed."
script {
statusHasChanged = true
}
}
success {
echo "Build success."
// email when changed to success
script {
if (statusHasChanged || env.EMAIL_NOTIFICATION == 'true') {
emailext(body: '${DEFAULT_CONTENT}',
subject: '${DEFAULT_SUBJECT}',
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS',
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
}
}
}
failure {
echo "Build failure."
// always email on failure
emailext(body: '${DEFAULT_CONTENT}',
subject: '${DEFAULT_SUBJECT}',
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS',
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
}
}
}