-
Notifications
You must be signed in to change notification settings - Fork 25
/
Jenkinsfile
377 lines (344 loc) · 11.3 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#!/usr/bin/env groovy
def ircNotification(result) {
def server = "icann.irc.meshnet.pl"
def port = "6667"
def nick = "JENC_${BUILD_NUMBER}"
def channel = '#antinet-build'
result = result.toUpperCase()
def message = "Project ${JOB_NAME} build #${BUILD_NUMBER}: ${result}: ${BUILD_URL}"
node {
sh """
(
echo NICK ${nick}
echo USER ${nick} 8 * : ${nick}
sleep 5
echo "JOIN ${channel}"
echo "NOTICE ${channel} :${message}"
echo QUIT
) | nc ${server} ${port}
"""
}
}
def native_linux(git_url, branch) {
build job: 'galaxy42_linux',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['debian'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def native_windows_mingw32(git_url, branch) {
build job: 'galaxy42_mingw_32bit',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['win32&&cygwin'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def native_windows_mingw64(git_url, branch) {
build job: 'galaxy42_mingw_64bit',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['win64&&cygwin'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def native_windows_msvc(git_url, branch) {
build job: 'galaxy42_MSVC',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['win64&&msvc'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def run_unit_test(git_url, branch) {
build job: 'galaxy42_unit-tests',
parameters: [ [$class: 'LabelParameterValue',
name: 'UnitTest',
label: 'allow_unittests' ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def run_integration_test() {
build job: 'galaxy42_integration-tests',
parameters: [ [$class: 'LabelParameterValue',
name: 'Integration',
labels: ['allow_integrationtests'] ] ]
}
def run_memory_test(git_url, branch) {
build job: 'g42_safe-memory',
parameters: [ [$class: 'NodeParameterValue',
name: 'MemTest',
labels: ['allow_memtest'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def run_thread_ub_test(git_url, branch) {
build job: 'g42_safe-thread-ub',
parameters: [ [$class: 'NodeParameterValue',
name: 'ThubTest',
labels: ['allow_thread_ub_test'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def native_mac(git_url, branch) {
build job: 'galaxy42_mac_native',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['mac_native'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
def native_gui(git_url, branch) {
build job: 'galaxy42_gui',
parameters: [ [$class: 'NodeParameterValue',
name: 'Multinode',
labels: ['gui'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "$git_url" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "$branch" ] ]
}
// build trigger - checking changes every 5 min
properties([pipelineTriggers([ [$class: 'GitHubPushTrigger'],
[$class: "SCMTrigger", scmpoll_spec: "H/5 * * * *"]
])
])
node('master') {
properties([disableConcurrentBuilds()])
def build_native_linux = true
def build_native_windows_mingw32 = true
def build_native_windows_mingw64 = true
def build_native_windows_msvc = true
def build_native_mac = true
def build_native_gui = true
def should_run_unit_test = true
def should_run_integration_test = true
def should_run_memory_test = true
def should_run_thread_ub_test = true
def build_gitian_linux = false
def build_gitian_macosx = false
def build_gitian_windows = false
def GIT_REPOSITORY_URL = scm.getUserRemoteConfigs()[0].getUrl()
println "GIT_URL: [$GIT_REPOSITORY_URL]"
//git repository branch could be passed on jenkins build configuration as regular expresion, more info: Jenkins Git plugin
//def GIT_BRANCH = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
def GIT_BRANCH = ""
if (env.BRANCH_NAME.startsWith("PR-")) {
println "Detect Pull Request ${env.BRANCH_NAME}"
def PRNumber = env.BRANCH_NAME.tokenize("PR-")[0]
//def gitURLcommand = 'git config --local remote.origin.url'
//gitURL = sh(returnStdout: true, script: gitURLcommand).trim()
println "PRNumber=PR number: [$PRNumber]"
GIT_BRANCH = "origin/pr/${PRNumber}/head"
} else {
GIT_BRANCH = "${env.BRANCH_NAME}"
}
println "BRANCH: [$GIT_BRANCH]"
def failure_counter=0
parallel (
linux: {
if(build_native_linux) {
stage('linux') {
native_linux(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
},
windows_mingw32: {
if(build_native_windows_mingw32) {
stage('windows_mingw32') {
native_windows_mingw32(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
},
windows_mingw64: {
if(build_native_windows_mingw64) {
stage('windows_mingw64') {
native_windows_mingw64(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
},
windows_msvc: {
if(build_native_windows_msvc) {
stage('windows_MSVC') {
native_windows_msvc(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
},
mac: {
if(build_native_mac) {
stage('mac') {
native_mac(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
},
gui: {
if(build_native_gui) {
stage('gui') {
native_gui(GIT_REPOSITORY_URL,GIT_BRANCH)
}
}
}
)
if (should_run_unit_test) {
stage('unit_test') {
try {
run_unit_test(GIT_REPOSITORY_URL,GIT_BRANCH)
} catch (all) {
println "Unit_Test fail, {$all}\nbut we continue."
failure_counter++
}
}
}
if (should_run_integration_test) {
stage('integration_tests') {
try {
run_integration_test()
} catch (all) {
println "Integration_tests probably fails, {$all}\nbut we continue to next stage."
println "Check individual item build console log for details."
failure_counter++
}
}
}
parallel (
memory_test: {
if (should_run_memory_test) {
stage('memory_test') {
try {
run_memory_test(GIT_REPOSITORY_URL,GIT_BRANCH)
} catch (all) {
println "Memory test fail, {$all}\nbut we continue."
failure_counter++
}
}
}
},
thread_ub_test: {
if (should_run_thread_ub_test) {
stage('thread_ub_test') {
try {
run_thread_ub_test(GIT_REPOSITORY_URL,GIT_BRANCH)
} catch (all) {
println "Thread and undefined behaviors test fail, {$all}\nbut we continue."
failure_counter++
}
}
}
}
)
if (build_gitian_linux) {
stage('deterministic_linux') {
try {
build job: 'galaxy42_gitian_-L',
parameters: [ [$class: 'NodeParameterValue',
name: 'Gitian_linux',
labels: ['allow_gitian'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "${GIT_REPOSITORY_URL}" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "${GIT_BRANCH}" ] ]
} catch (all) {
println "Gitian_build_linux probably fails, {$all}\nbut we continue to next stage."
println "Check individual item build console log for details."
failure_counter++
}
}
}
if (build_gitian_macosx) {
stage('deterministic_macosx') {
try {
build job: 'galaxy42_gitian_-M',
parameters: [ [$class: 'NodeParameterValue',
name: 'Gitian_osx',
labels: ['allow_gitian'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "${GIT_REPOSITORY_URL}" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "${GIT_BRANCH}" ] ]
} catch (all) {
println "Gitian_build_macosx probably fails, {$all}\nbut we continue to next stage."
println "Check individual item build console log for details."
failure_counter++
}
}
}
if (build_gitian_windows) {
stage('deterministic_windows') {
try {
build job: 'galaxy42_gitian_-W',
parameters: [ [$class: 'NodeParameterValue',
name: 'Gitian_windows',
labels: ['allow_gitian'],
nodeEligibility: [$class: 'AllNodeEligibility'] ],
[$class: 'StringParameterValue',
name: 'git_repository_url',
value: "${GIT_REPOSITORY_URL}" ],
[$class: 'StringParameterValue',
name: 'git_branch',
value: "${GIT_BRANCH}" ] ]
} catch (all) {
println "Gitian_build_windows probably fails, {$all}\nbut we continue to next stage."
failure_counter++
}
}
}
if(failure_counter > 0) {
println "At least one stage has failed, make pipeline build failure"
currentBuild.result = 'FAILURE'
println "Check individual item build - console log for details."
} else {
currentBuild.result = 'SUCCESS'
}
node('debian') {
ircNotification(currentBuild.result)
}
}