-
Notifications
You must be signed in to change notification settings - Fork 35
/
Jenkinsfile
597 lines (508 loc) · 34.5 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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
env.ghprbGhRepository = env.ghprbGhRepository ?: 'CentOS-PaaS-SIG/ci-pipeline'
env.ghprbActualCommit = env.ghprbActualCommit ?: 'master'
env.ghprbPullAuthorLogin = env.ghprbPullAuthorLogin ?: ''
env.TARGET_BRANCH = env.TARGET_BRANCH ?: 'master'
// Needed for podTemplate()
env.SLAVE_TAG = env.SLAVE_TAG ?: 'stable'
env.RPMBUILD_TAG = env.RPMBUILD_TAG ?: 'stable'
env.RSYNC_TAG = env.RSYNC_TAG ?: 'stable'
env.OSTREE_COMPOSE_TAG = env.OSTREE_COMPOSE_TAG ?: 'stable'
env.OSTREE_IMAGE_COMPOSE_TAG = env.OSTREE_IMAGE_COMPOSE_TAG ?: 'stable'
env.SINGLEHOST_TEST_TAG = env.SINGLEHOST_TEST_TAG ?: 'stable'
env.OSTREE_BOOT_IMAGE_TAG = env.OSTREE_BOOT_IMAGE_TAG ?: 'stable'
env.LINCHPIN_LIBVIRT_TAG = env.LINCHPIN_LIBVIRT_TAG ?: 'stable'
env.DOCKER_REPO_URL = env.DOCKER_REPO_URL ?: '172.30.254.79:5000'
env.OPENSHIFT_NAMESPACE = env.OPENSHIFT_NAMESPACE ?: 'continuous-infra'
env.OPENSHIFT_SERVICE_ACCOUNT = env.OPENSHIFT_SERVICE_ACCOUNT ?: 'jenkins'
// Audit file for all messages sent.
msgAuditFile = "messages/message-audit.json"
// IRC properties
IRC_NICK = "contra-bot"
IRC_CHANNEL = "#contra-ci-cd"
// Number of times to keep retrying to make sure message is ingested
// by datagrepper
fedmsgRetryCount = 120
// Execution ID for this run of the pipeline
executionID = UUID.randomUUID().toString()
// Pod name to use
podName = 'fedora-atomic-' + executionID + '-' + TARGET_BRANCH
library identifier: "ci-pipeline@${env.ghprbActualCommit}",
retriever: modernSCM([$class: 'GitSCMSource',
remote: "https://github.com/${env.ghprbGhRepository}",
traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'],
[$class: 'RefSpecsSCMSourceTrait',
templates: [[value: '+refs/heads/*:refs/remotes/@{remote}/*'],
[value: '+refs/pull/*:refs/remotes/origin/pr/*']]]]])
properties(
[
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '', daysToKeepStr: '90', numToKeepStr: '')),
disableConcurrentBuilds(),
parameters(
[
string(name: 'CI_MESSAGE',
description: 'CI Message that triggered the pipeline'),
string(name: 'TARGET_BRANCH',
defaultValue: 'f26',
description: 'Fedora target branch'),
string(name: 'HTTP_SERVER',
defaultValue: '',
description: 'HTTP Server'),
string(name: 'HTTP_DIR',
defaultValue: '',
description: 'HTTP dir'),
string(name: 'RSYNC_USER',
defaultValue: '',
description: 'RSync User'),
string(name: 'RSYNC_SERVER',
defaultValue: '',
description: 'RSync Server'),
string(name: 'RSYNC_DIR',
defaultValue: '',
description: 'RSync Dir'),
string(name: 'PROJECT_REPO',
defaultValue: 'ci-pipeline',
description: 'Main project repo'),
string(name: 'MAIN_TOPIC',
defaultValue: '',
description: 'Main topic to publish on'),
string(name: 'MSG_PROVIDER',
defaultValue: 'fedora-fedmsg',
description: 'Main provider to send messages on'),
string(name: 'FEDORA_PRINCIPAL',
defaultValue: '',
description: 'Principal for authenticating with fedora build system'),
string(name: 'ghprbActualCommit',
defaultValue: 'master',
description: 'The GitHub pull request commit'),
string(name: 'ghprbGhRepository',
defaultValue: 'CentOS-PaaS-SIG/ci-pipeline',
description: 'The repo the PR is against'),
string(name: 'sha1',
defaultValue: '',
description: ''),
string(name: 'ghprbPullId',
defaultValue: '',
description: 'The GitHub pull request number'),
string(name: 'ghprbPullAuthorLogin',
defaultValue: '',
description: 'Who raised the GitHub pull request'),
string(name: 'SLAVE_TAG',
defaultValue: 'stable',
description: 'Tag for slave image'),
string(name: 'OSTREE_BOOT_IMAGE_TAG',
defaultValue: 'stable',
description: 'Tag for ostree boot image'),
string(name: 'RPMBUILD_TAG',
defaultValue: 'stable',
description: 'Tag for rpmbuild image'),
string(name: 'RSYNC_TAG',
defaultValue: 'stable',
description: 'Tag for rsync image'),
string(name: 'OSTREE_COMPOSE_TAG',
defaultValue: 'stable',
description: 'Tag for ostree-compose image'),
string(name: 'OSTREE_IMAGE_COMPOSE_TAG',
defaultValue: 'stable',
description: 'Tag for ostree-image-compose image'),
string(name: 'SINGLEHOST_TEST_TAG',
defaultValue: 'stable',
description: 'Tag for singlehost test image'),
string(name: 'LINCHPIN_LIBVIRT_TAG',
defaultValue: 'stable',
description: 'Tag for linchpin-libvirt image'),
string(name: 'DOCKER_REPO_URL',
defaultValue: '172.30.254.79:5000',
description: 'Docker repo url for Openshift instance'),
string(name: 'OPENSHIFT_NAMESPACE',
defaultValue: 'continuous-infra',
description: 'Project namespace for Openshift operations'),
string(name: 'OPENSHIFT_SERVICE_ACCOUNT',
defaultValue: 'jenkins',
description: 'Service Account for Openshift operations'),
booleanParam(name: 'GENERATE_IMAGE',
defaultValue: false,
description: 'Force generation of the image'),
]
),
]
)
podTemplate(name: podName,
label: podName,
cloud: 'openshift',
serviceAccount: OPENSHIFT_SERVICE_ACCOUNT,
idleMinutes: 0,
namespace: OPENSHIFT_NAMESPACE,
containers: [
// This adds the custom slave container to the pod. Must be first with name 'jnlp'
containerTemplate(name: 'jnlp',
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/jenkins-continuous-infra-slave:' + SLAVE_TAG,
ttyEnabled: false,
args: '${computer.jnlpmac} ${computer.name}',
command: '',
workingDir: '/workDir'),
// This adds the rpmbuild test container to the pod.
containerTemplate(name: 'rpmbuild',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/rpmbuild:' + RPMBUILD_TAG,
ttyEnabled: true,
command: 'cat',
privileged: true,
workingDir: '/workDir'),
// This adds the rsync test container to the pod.
containerTemplate(name: 'rsync',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/rsync:' + RSYNC_TAG,
ttyEnabled: true,
command: 'cat',
privileged: true,
workingDir: '/workDir'),
// This adds the ostree-compose test container to the pod.
containerTemplate(name: 'ostree-compose',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/ostree-compose:' + OSTREE_COMPOSE_TAG,
ttyEnabled: true,
command: 'cat',
privileged: true,
workingDir: '/workDir'),
// This adds the ostree-image-compose test container to the pod.
containerTemplate(name: 'ostree-image-compose',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/ostree-image-compose:' + OSTREE_IMAGE_COMPOSE_TAG,
ttyEnabled: true,
command: 'cat',
privileged: true,
workingDir: '/workDir'),
// This adds the singlehost test container to the pod.
containerTemplate(name: 'singlehost-test',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/singlehost-test:' + SINGLEHOST_TEST_TAG,
ttyEnabled: true,
command: 'cat',
// Request - minimum required, Limit - maximum possible (hard quota)
// https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-cpu
// https://blog.openshift.com/managing-compute-resources-openshiftkubernetes/
resourceRequestCpu: '500m',
resourceLimitCpu: '1',
resourceRequestMemory: '2Gi',
resourceLimitMemory: '4Gi',
privileged: true,
workingDir: '/workDir'),
// This adds the ostree boot image container to the pod.
containerTemplate(name: 'ostree-boot-image',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/ostree-boot-image:' + OSTREE_BOOT_IMAGE_TAG,
ttyEnabled: true,
command: '/usr/sbin/init',
privileged: true,
workingDir: '/workDir'),
containerTemplate(name: 'linchpin-libvirt',
alwaysPullImage: true,
image: DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/linchpin-libvirt:' + LINCHPIN_LIBVIRT_TAG,
ttyEnabled: true,
command: '/usr/sbin/init',
privileged: true,
workingDir: '/workDir')
],
volumes: [emptyDirVolume(memory: false, mountPath: '/sys/class/net')])
{
node(podName) {
def currentStage = ""
ansiColor('xterm') {
timestamps {
// We need to set env.HOME because the openshift slave image
// forces this to /home/jenkins and then ~ expands to that
// even though id == "root"
// See https://github.com/openshift/jenkins/blob/master/slave-base/Dockerfile#L5
//
// Even the kubernetes plugin will create a pod with containers
// whose $HOME env var will be its workingDir
// See https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java#L311
//
env.HOME = "/root"
//
try {
// Prepare our environment
currentStage = "prepare-environment"
stage(currentStage) {
deleteDir()
// Set our default env variables
pipelineUtils.setDefaultEnvVars()
// Prepare Credentials (keys, passwords, etc)
pipelineUtils.prepareCredentials()
// Parse the CI_MESSAGE and inject it as env vars
pipelineUtils.injectFedmsgVars(env.CI_MESSAGE)
// Set RSYNC_BRANCH for rsync'ing to artifacts store
env.RSYNC_BRANCH = pipelineUtils.getRsyncBranch()
// Decorate our build
pipelineUtils.updateBuildDisplayAndDescription()
// Gather some info about the node we are running on for diagnostics
pipelineUtils.verifyPod(OPENSHIFT_NAMESPACE, env.NODE_NAME)
// create audit message file
pipelineUtils.initializeAuditFile(msgAuditFile)
}
// Set our current stage value
currentStage = "ci-pipeline-rpmbuild"
stage(currentStage) {
// SCM
dir('ci-pipeline') {
// Checkout our ci-pipeline repo based on the value of env.ghprbActualCommit
checkout([$class: 'GitSCM', branches: [[name: env.ghprbActualCommit]],
doGenerateSubmoduleConfigurations: false,
extensions : [],
submoduleCfg : [],
userRemoteConfigs : [
[refspec:
'+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/* ',
url: "https://github.com/${env.ghprbGhRepository}"]
]
])
}
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
// Return a map (messageFields) of our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("package.running")
// Send message org.centos.prod.ci.pipeline.package.running on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Execute rpmbuild-test script in rpmbuild container
pipelineUtils.executeInContainer(currentStage, "rpmbuild", "/tmp/rpmbuild-test.sh")
def package_props = "${env.WORKSPACE}/" + currentStage + "/logs/package_props.txt"
def package_props_groovy = "${env.WORKSPACE}/package_props.groovy"
pipelineUtils.convertProps(package_props, package_props_groovy)
load(package_props_groovy)
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("package.complete")
// Send message org.centos.prod.ci.pipeline.package.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
}
currentStage = "ci-pipeline-ostree-compose"
stage(currentStage) {
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
//Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("compose.running")
// Send message org.centos.prod.ci.pipeline.compose.running on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Get previous ostree artifacts
env.rsync_paths = "ostree"
env.rsync_from = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
env.rsync_to = "${env.WORKSPACE}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-before", "rsync", "/tmp/rsync.sh")
// Compose new ostree
pipelineUtils.executeInContainer(currentStage, "ostree-compose", "/tmp/ostree-compose.sh")
// Push new ostree compose to artifacts server
env.rsync_to = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
env.rsync_from = "${env.WORKSPACE}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-after", "rsync", "/tmp/rsync.sh")
// Load ostree properties as variables
def ostree_props = "${env.WORKSPACE}/" + currentStage + "/logs/ostree.props"
def ostree_props_groovy = "${env.WORKSPACE}/ostree.props.groovy"
pipelineUtils.convertProps(ostree_props, ostree_props_groovy)
load(ostree_props_groovy)
// Rsync push logs
env.rsync_paths = "."
env.rsync_from = "${env.WORKSPACE}/" + currentStage + "/logs/"
env.rsync_to = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/images/${env.imgname}/" + currentStage + "/"
pipelineUtils.executeInContainer(currentStage + "-rsync-logs", "rsync", "/tmp/rsync.sh")
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("compose.complete")
// Send message org.centos.prod.ci.pipeline.compose.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
pipelineUtils.checkLastImage(currentStage)
}
currentStage = "ci-pipeline-ostree-image-compose"
stage(currentStage) {
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
// We always run, but don't always push to artifacts
env.PUSH_IMAGE = "false"
// Check if a new ostree image compose is needed
if (fileExists("${env.WORKSPACE}/NeedNewImage.txt") || ("${env.GENERATE_IMAGE}" == "true")) {
// We will push a new qcow2 to artifacts
env.PUSH_IMAGE = "true"
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("image.running")
// Send message org.centos.prod.ci.pipeline.image.running on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
}
// Rsync pull from artifacts
env.rsync_paths = "netinst ostree images"
env.rsync_from = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
env.rsync_to = "${env.WORKSPACE}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-before", "rsync", "/tmp/rsync.sh")
// Compose image
pipelineUtils.executeInContainer(currentStage, "ostree-image-compose", "/tmp/ostree-image-compose.sh")
// Rsync push netinst
env.rsync_paths = "netinst"
env.rsync_from = "${env.WORKSPACE}/"
env.rsync_to = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-push-netinst", "rsync", "/tmp/rsync.sh")
String untested_img_loc = "${env.WORKSPACE}/images/untested-atomic.qcow2"
sh script: "cp -f ${untested_img_loc} ${env.WORKSPACE}/", label: "Copying ${untested_img_loc} to the ${env.WORKSPACE}/"
if (fileExists("${env.WORKSPACE}/NeedNewImage.txt") || ("${env.GENERATE_IMAGE}" == "true")) {
// Rsync push images
env.rsync_paths = "images"
pipelineUtils.executeInContainer(currentStage + "-rsync-after-netinst", "rsync", "/tmp/rsync.sh")
// These variables will mess with boot sanity jobs
// later if they are injected from a non pushed img
def ostree_props = "${env.WORKSPACE}/" + currentStage + "/logs/ostree.props"
def ostree_props_groovy = "${env.WORKSPACE}/ostree.props.groovy"
pipelineUtils.convertProps(ostree_props, ostree_props_groovy)
load(ostree_props_groovy)
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("image.complete")
// Send message org.centos.prod.ci.pipeline.image.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
} else {
echo "Not Pushing a New Image"
}
// Rsync push logs
env.rsync_paths = "."
env.rsync_from = "${env.WORKSPACE}/" + currentStage + "/logs/"
env.rsync_to = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/images/${env.imgname}/" + currentStage + "/"
pipelineUtils.executeInContainer(currentStage + "-rsync-logs", "rsync", "/tmp/rsync.sh")
}
currentStage = "ci-pipeline-ostree-image-boot-sanity"
stage(currentStage) {
if (fileExists("${env.WORKSPACE}/NeedNewImage.txt") || ("${env.GENERATE_IMAGE}" == "true")) {
pipelineUtils.setStageEnvVars(currentStage)
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("image.test.smoke.running")
// Send message org.centos.prod.ci.pipeline.image.test.smoke.running on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Rsync pull images dir from artifacts
env.rsync_paths = "images"
env.rsync_from = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
env.rsync_to = "${env.WORKSPACE}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-before", "rsync", "/tmp/rsync.sh")
// Run boot sanity on image
pipelineUtils.executeInContainer(currentStage, "ostree-boot-image", "/home/ostree-boot-image.sh")
// If boot sanity passes, we update images dir on artifacts
env.rsync_to = "${env.RSYNC_USER}@${env.RSYNC_SERVER}::${env.RSYNC_DIR}/${env.RSYNC_BRANCH}/"
env.rsync_from = "${env.WORKSPACE}/"
pipelineUtils.executeInContainer(currentStage + "-rsync-after", "rsync", "/tmp/rsync.sh")
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("image.test.smoke.complete")
// Send message org.centos.prod.ci.pipeline.image.test.smoke.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
} else {
echo "Not Running Image Boot Sanity on Image"
}
}
currentStage = "ci-pipeline-ostree-boot-sanity"
stage(currentStage) {
pipelineUtils.setStageEnvVars(currentStage)
// Run ostree boot sanity
pipelineUtils.executeInContainer(currentStage, "ostree-boot-image", "/home/ostree-boot-image.sh")
}
currentStage = "ci-pipeline-functional-tests"
stage(currentStage) {
// Only run this stage if tests exist
if (!pipelineUtils.checkTests(env.fed_repo, env.fed_branch, 'atomic')) {
pipelineUtils.skip(currentStage)
} else {
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("package.test.functional.queued")
// Send message org.centos.prod.ci.pipeline.package.test.functional.queued on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
//Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("package.test.functional.running")
// Send message org.centos.prod.ci.pipeline.package.test.functional.running on fedmsg
pipelineUtils.sendMessage(messageFields['topic'], messageFields['properties'], messageFields['content'])
// Run functional tests
try {
pipelineUtils.executeInContainer(currentStage, "singlehost-test", "/tmp/package-test.sh")
} catch (e) {
if (pipelineUtils.fileExists("${WORKSPACE}/${currentStage}/logs/test.log")) {
currentBuild.result = 'UNSTABLE'
} else {
throw e
}
}
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("package.test.functional.complete")
// Send message org.centos.prod.ci.pipeline.package.test.functional.complete on fedmsg
pipelineUtils.sendMessage(messageFields['topic'], messageFields['properties'], messageFields['content'])
}
}
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("compose.test.integration.queued")
// Send message org.centos.prod.ci.pipeline.compose.test.integration.queued on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
currentStage = "ci-pipeline-atomic-host-tests"
stage(currentStage) {
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("compose.test.integration.running")
// Send message org.centos.prod.ci.pipeline.compose.test.integration.running on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Run integration tests
try {
pipelineUtils.executeInContainer(currentStage, "singlehost-test", "/tmp/integration-test.sh")
} catch (e) {
// Should improve to actually parse result files, but for now if the script failed, call it a test failure
currentBuild.result = 'UNSTABLE'
}
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("compose.test.integration.complete")
// Send message org.centos.prod.ci.pipeline.compose.test.integration.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
}
currentStage = "openshift-e2e-tests"
stage(currentStage) {
// run linchpin up and other steps
// note: need to be updated
// Set stage specific vars
pipelineUtils.setStageEnvVars(currentStage)
// run linchpin workspace for e2e tests
try {
pipelineUtils.executeInContainer(currentStage, "linchpin-libvirt", "/root/linchpin_workspace/run_e2e_tests.sh")
} catch (e) {
// Should improve to actually parse result files, but for now if the script failed, call it a test failure
currentBuild.result = 'UNSTABLE'
}
}
} catch (e) {
// Set build result
currentBuild.result = 'FAILURE'
// Report the exception
echo "Error: Exception from " + currentStage + ":"
echo e.getMessage()
// Send message org.centos.prod.ci.pipeline.<stage>.complete on fedmsg if stage failed
// as the execution of stage would have stopped with executeInContainer call
messageFields = pipelineUtils.setMessageFields(currentStage)
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
// Throw the error
throw e
} finally {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
// Set the build display name and description
pipelineUtils.setBuildDisplayAndDescription()
// only post to IRC on a failure
if (currentBuild.result == 'FAILURE') {
// only if this is a production build
if (env.ghprbActualCommit == null || env.ghprbActualCommit == "master") {
def message = "${JOB_NAME} build #${BUILD_NUMBER}: ${currentBuild.currentResult}: ${BUILD_URL}"
pipelineUtils.sendIRCNotification("${IRC_NICK}-${UUID.randomUUID()}", IRC_CHANNEL, message)
}
}
try {
pipelineUtils.getContainerLogsFromPod(OPENSHIFT_NAMESPACE, env.NODE_NAME)
} catch (e) {
// Report the exception
echo "Warning: Could not get containerLogsFromPod: "
echo e.getMessage()
}
// Archive our artifacts
step([$class: 'ArtifactArchiver', allowEmptyArchive: true, artifacts: '**/logs/**,*.txt,*.groovy,**/job.*,**/*.groovy,**/inventory.*', excludes: '**/job.props,**/job.props.groovy,**/*.example', fingerprint: true])
// Set our message topic, properties, and content
messageFields = pipelineUtils.setMessageFields("complete")
// Send message org.centos.prod.ci.pipeline.complete on fedmsg
pipelineUtils.sendMessageWithAudit(messageFields['topic'], messageFields['properties'], messageFields['content'], msgAuditFile, fedmsgRetryCount)
}
}
}
}
}