-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathJenkinsfile
More file actions
1832 lines (1769 loc) · 85.9 KB
/
Copy pathJenkinsfile
File metadata and controls
1832 lines (1769 loc) · 85.9 KB
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/groovy
/* groovylint-disable-next-line LineLength */
/* groovylint-disable DuplicateMapLiteral, DuplicateNumberLiteral */
/* groovylint-disable DuplicateStringLiteral, NestedBlockDepth */
/* groovylint-disable ParameterName, VariableName */
/* Copyright 2019-2024 Intel Corporation
/* Copyright 2025 Google LLC
* Copyright 2025-2026 Hewlett Packard Enterprise Development LP
* All rights reserved.
*
* This file is part of the DAOS Project. It is subject to the license terms
* in the LICENSE file found in the top-level directory of this distribution
* and at https://img.shields.io/badge/License-BSD--2--Clause--Patent-blue.svg.
* No part of the DAOS Project, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*/
import groovy.transform.Field
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
// To use a test branch (i.e. PR) until it lands to master
// I.e. for testing library changes
//@Library(value='pipeline-lib@your_branch') _
@Library(value='pipeline-lib@hendersp/DAOS-18348') _
// The trusted-pipeline-lib daosLatestVersion() method will convert this into a number
/* groovylint-disable-next-line CompileStatic, VariableName */
String next_version() {
return 'release/2.8'
}
/* groovylint-disable-next-line CompileStatic */
job_status_internal = [:]
// Keys and values updated by the updateRunStage() function using the parameters.
@Field
Map<String, Boolean> runStage = [:]
// Update the runStage map
void updateRunStage() {
Map reasons = [:]
// Ordered list of stage names as params.keySet() does not guarantee order
List<String> stageOrder = [
'Cancel Previous Builds',
'Pre-build',
'Python Bandit check',
'Build',
'Build on EL 8',
'Build on EL 9',
'Build on Leap 15',
'Build on EL 9 with Bullseye',
'Unit Tests',
'Unit Test',
'Unit Test bdev',
'NLT',
'NLT with Bullseye',
'Unit Test with memcheck',
'Unit Test bdev with memcheck',
'Test',
'Functional on EL 8.8 with Valgrind',
'Functional on EL 8',
'Functional on EL 9',
'Functional on Leap 15',
'Functional on SLES 15',
'Functional on Ubuntu 20.04',
'Fault injection testing',
'Test RPMs on EL 9.6',
'Test RPMs on Leap 15.5',
'Test Hardware',
'Functional Hardware Medium',
'Functional Hardware Medium MD on SSD',
'Functional Hardware Medium VMD',
'Functional Hardware Medium Verbs Provider',
'Functional Hardware Medium Verbs Provider MD on SSD',
'Functional Hardware Medium UCX Provider',
'Functional Hardware Large',
'Functional Hardware Large MD on SSD'
]
// Initialize the run state of each stage using the parameter stage keys
for (name in stageOrder) {
value = params.get(name, null)
if (value instanceof Boolean && !name.startsWith('CI_')) {
runStage[name] = value
reasons[name] = "parameter selection or default"
}
}
// Handle doc-only changes: Only run default or selected build stages
if (docOnlyChange(target_branch)) {
println("updateRunStage: Detected doc-only change, skipping testing")
for (stage in runStage.keySet()) {
if (stage in ['Unit Tests', 'Test', 'Test Hardware']) {
runStage[stage] = false
reasons[stage] = "doc-only change"
}
}
displayRunStage(reasons)
return
}
// Handle landing builds
if (startedByLanding()) {
println("updateRunStage: Detected landing build, overwriting defaults")
for (stage in runStage.keySet()) {
runStage[stage] = false
if (stage in ['Pre-build', 'Python Bandit check', 'Build', 'Unit Tests', 'Test']
|| stage.contains('Build on')
|| stage.contains('Unit Test')
|| stage.contains('NLT')
|| stage.contains('Fault injection')
|| stage.contains('Test RPMs')
|| (stage.contains('Functional on') && !stage.contains('Ubuntu'))) {
runStage[stage] = true
}
reasons[stage] = "landing build"
}
displayRunStage(reasons)
return
}
// Handle user setting CI_RPM_TEST_VERSION or RPM-test-version
if (rpmTestVersion()) {
println("updateRunStage: Detected RPM test version, skipping build/RPM test stages")
for (stage in runStage.keySet()) {
if (stage.contains('Build')
|| stage.contains('Unit Tests')
|| stage.contains('Test RPMs')) {
runStage[stage] = false
reasons[stage] = "RPM test version"
}
}
displayRunStage(reasons)
return
}
// Handle user setting CI_FULL_BULLSEYE_REPORT
if (params.CI_FULL_BULLSEYE_REPORT) {
println("updateRunStage: Detected CI_FULL_BULLSEYE_REPORT, skipping unrelated stages")
for (stage in runStage.keySet()) {
if (stage in ['Build on EL 9 with Bullseye',
'Unit Test',
'Unit Test bdev',
'NLT with Bullseye',
'Functional on EL 9']) {
runStage[stage] = true
reasons[stage] = "CI_FULL_BULLSEYE_REPORT"
} else if (stage.contains('Functional Hardware')) {
runStage[stage] = true
reasons[stage] = "CI_FULL_BULLSEYE_REPORT"
} else if (stage in ['Build on EL 8',
'Build on EL 9',
'Build on Leap 15',
'NLT',
'Unit Test with memcheck',
'Unit Test bdev with memcheck',
'Functional on EL 8.8 with Valgrind',
'Functional on EL 8',
'Functional on Leap 15',
'Functional on SLES 15',
'Functional on Ubuntu 20.04',
'Fault injection testing',
'Test RPMs on EL 9.6',
'Test RPMs on Leap 15.5']) {
runStage[stage] = false
reasons[stage] = "CI_FULL_BULLSEYE_REPORT"
}
}
displayRunStage(reasons)
return
}
// Handle user setting CI_BUILD_PACKAGES_ONLY
if (params.CI_BUILD_PACKAGES_ONLY) {
println("updateRunStage: Detected CI_BUILD_PACKAGES_ONLY, skipping unit test stages")
for (stage in runStage.keySet()) {
if (stage.contains('Unit Tests')) {
runStage[stage] = false
reasons[stage] = "CI_BUILD_PACKAGES_ONLY"
} else if (stage.contains('Build')) {
runStage[stage] = true
reasons[stage] = "CI_BUILD_PACKAGES_ONLY"
}
}
displayRunStage(reasons)
return
}
// Handle builds started by the user
if (startedByUser()) {
println("updateRunStage: Build started by the user, skipping commit pragma checks")
displayRunStage(reasons)
return
}
// Update stage running based on commit pragmas
println("updateRunStage: Converting env.pragmas string back into a Map: ${env.pragmas}")
Map<String, String> commitPragmas = envToPragmas()
println("updateRunStage: Checking skip commit pragmas from commit message:")
commitPragmas.each { key, value ->
println(" ${key}: ${value}")
}
for (stage in runStage.keySet()) {
List<String> skipPragmas = getStageNameSkipPragmas(stage)
for (pragma in skipPragmas) {
// commitPragmas will already contain lower case keys from pragmasToMap()
println("updateRunStage: ${stage} checking for a ${pragma} commit pragma")
if (commitPragmas.get(pragma, '').toLowerCase() == 'true') {
runStage[stage] = false
reasons[stage] = "commit pragma ${pragma}: true"
break
} else if (commitPragmas.get(pragma, '').toLowerCase() == 'false') {
runStage[stage] = true
reasons[stage] = "commit pragma ${pragma}: false"
break
}
}
}
displayRunStage(reasons)
}
// Log which stages will be run and why based on the current state of the runStage map
void displayRunStage(Map reasons = [:]) {
println("Stage run conditions:")
for (stage in runStage.keySet()) {
String reason = reasons.get(stage, 'default')
if (runStage[stage]) {
echo("Running: ${stage} (reason: ${reason})")
} else {
echo("Skipping: ${stage} (reason: ${reason})")
}
}
}
// Get a list of skip commit pragmas to check for a given stage name
List<String> getStageNameSkipPragmas(String stageName) {
String stagePragma = "skip-${stageName.replaceAll(' ', '-').toLowerCase()}"
List<String> pragmas = []
// Build up a priority list of pragmas to check based on the stage name.
if (stageName in ['Cancel Previous Builds', 'Pre-build']) {
// Add skip pragma for this stage
pragmas.add(stagePragma)
} else if (stageName == 'Python Bandit check') {
// Add skip pragma for this stage
pragmas.add(stagePragma)
// Compatibility with existing commit pragmas
pragmas.add(stagePragma.replace('-bandit-check', '-bandit'))
} else if (stageName.contains('Build')) {
// Add skip pragma for parent stage
if (stageName != 'Build') {
pragmas.add('skip-build')
}
// Add skip pragma for this stage
pragmas.add(stagePragma)
// Compatibility with existing commit pragmas
if (stagePragma.contains('build-on-')) {
pragmas.add(stagePragma.replace('build-on-', 'build-'))
}
} else if (stageName.contains('Unit Test') || stageName.contains('NLT')) {
// Add skip pragma for parent stage
if (stageName != 'Unit Tests') {
pragmas.add('skip-unit-tests')
}
// Add skip pragma for this stage
pragmas.add(stagePragma)
// Compatibility with existing commit pragmas
if (stagePragma.contains('-with-')) {
pragmas.add(stagePragma.replace('-with-', '-'))
}
} else if (stageName == 'Test' || stageName.contains('Functional on')
|| stageName.contains('Fault injection') || stageName.contains('Test RPMs')) {
// Add skip pragma for parent stage
if (stageName != 'Test') {
pragmas.add('skip-test')
}
if (stageName.contains('Functional on')) {
// Add skip pragma alias for all functional tests
pragmas.add('skip-func-test')
// Add skip pragma alias for all functional VM tests
pragmas.add('skip-func-test-vm')
pragmas.add('skip-func-vm-test')
// Compatibility with existing commit pragmas
pragmas.add(stagePragma.replace('functional-on-', 'func-test-'))
} else if (stageName.contains('Test RPMs on')) {
// Add skip pragma alias for all RPM tests
pragmas.add('skip-test-rpms')
} else if (stageName.contains('Fault injection')) {
// Compatibility with existing commit pragmas
pragmas.add('skip-fault-injection-test')
}
// Add skip pragma for this stage
pragmas.add(stagePragma)
} else if (stageName.contains('Hardware')) {
if (stageName != 'Test Hardware') {
pragmas.add('skip-test-hardware')
pragmas.add('skip-test-hw')
}
if (stageName.contains('Functional')) {
// Add skip pragma alias for all functional tests
pragmas.add('skip-func-test')
// Add skip pragma alias for all functional HW tests
pragmas.add('skip-func-test-hw')
pragmas.add('skip-func-hw-test')
// Compatibility with existing commit pragmas
if (stagePragma.contains('functional-hardware-')) {
pragmas.add(stagePragma.replace('functional-hardware-', 'func-hw-test-'))
pragmas.add(stagePragma.replace('functional-hardware-', 'func-hw-'))
}
}
// Add skip pragma for this stage
pragmas.add(stagePragma)
// Support shortening hardware to hw
if (stagePragma.contains('hardware-')) {
pragmas.add(stagePragma.replace('hardware-', 'hw-'))
}
}
// Compatibility with existing commit pragmas using distro versions
List<String> distros = ['el', 'leap', 'sles', 'ubuntu']
List<String> copyPragmas = pragmas.clone()
for (distro in distros) {
for (_pragma in copyPragmas) {
if (_pragma.contains("-${distro}-")) {
pragmas.add(_pragma.replace("-${distro}-", "-${distro}"))
}
}
}
return pragmas
}
void get_rpm_relval() {
env.DAOS_RELVAL = sh(label: 'get git tag',
script: '''if [ -n "$GIT_CHECKOUT_DIR" ] && [ -d "$GIT_CHECKOUT_DIR" ]; then
cd "$GIT_CHECKOUT_DIR"
fi
if git diff-index --name-only HEAD^ | grep -q TAG; then
echo ""
else
echo ".$(git rev-list HEAD --count).g$(git rev-parse --short=8 HEAD)"
fi''',
returnStdout: true).trim()
}
// groovylint-disable-next-line MethodParameterTypeRequired, NoDef
void job_status_update(String name=env.STAGE_NAME, def value=currentBuild.currentResult) {
jobStatusUpdate(job_status_internal, name, value)
}
// groovylint-disable-next-line MethodParameterTypeRequired, NoDef
void job_step_update(def value=currentBuild.currentResult) {
// job_status_update(env.STAGE_NAME, value)
jobStatusUpdate(job_status_internal, env.STAGE_NAME, value)
}
// Don't define this as a type or it loses it's global scope
target_branch = env.CHANGE_TARGET ? env.CHANGE_TARGET : env.BRANCH_NAME
// bail out of branch builds that are not on a whitelist
if (!env.CHANGE_ID &&
(!env.BRANCH_NAME.startsWith('weekly-testing') &&
!env.BRANCH_NAME.startsWith('release/') &&
!env.BRANCH_NAME.startsWith('feature/') &&
!env.BRANCH_NAME.startsWith('ci-') &&
env.BRANCH_NAME != 'master')) {
currentBuild.result = 'SUCCESS'
return
}
// The docker agent setup and the provisionNodes step need to know the
// UID that the build agent is running under.
cached_uid = 0
Integer getuid() {
if (cached_uid == 0) {
cached_uid = sh(label: 'getuid()',
script: 'id -u',
returnStdout: true).trim()
}
return cached_uid
}
void fixup_rpmlintrc() {
if (env.SCONS_FAULTS_ARGS != 'BUILD_TYPE=dev') {
return
}
List go_bins = ['/usr/bin/dmg',
'/usr/bin/daos',
'/usr/bin/daos_agent',
'/usr/bin/hello_drpc',
'/usr/bin/daos_firmware',
'/usr/bin/daos_admin',
'/usr/bin/daos_server',
'/usr/bin/ddb']
String content = readFile(file: 'utils/rpms/daos.rpmlintrc') + '\n\n' +
'# https://daosio.atlassian.net/browse/DAOS-11534\n'
go_bins.each { bin ->
content += 'addFilter("W: position-independent-executable-suggested ' + bin + '")\n'
}
writeFile(file: 'utils/rpms/daos.rpmlintrc', text: content)
}
void uploadNewRPMs(String target, String stage) {
buildRpmPost target: target,
condition: stage,
rpmlint: false,
productArtifacts: ['daos', 'deps', 'bullseye']
}
String vm9_label(String distro) {
return cachedCommitPragma(pragma: distro + '-VM9-label',
def_val: cachedCommitPragma(pragma: 'VM9-label',
def_val: params.FUNCTIONAL_VM_LABEL))
}
void rpm_test_post(String stageName, String node) {
// Extract first node from comma-delimited list
String firstNode = node.split(',')[0].trim()
sh label: 'Fetch and stage artifacts',
script: 'hostname; ssh -i ci_key jenkins@' + firstNode +
' ls -ltar /tmp; mkdir -p "' + env.STAGE_NAME + '/" && ' +
'scp -i ci_key jenkins@' + firstNode +
':/tmp/{{suite_dmg,daos_{server_helper,{control,agent}}}.log,daos_server.log.*} "' +
stageName + '/"'
archiveArtifacts artifacts: env.STAGE_NAME + '/**'
job_status_update()
}
String sconsArgs() {
if (!params.CI_SCONS_ARGS) {
return sconsFaultsArgs()
}
println('Compiling DAOS with custom arguments')
return sconsFaultsArgs() + ' ' + params.CI_SCONS_ARGS
}
/**
* Update default commit pragmas based on files modified.
*/
Map update_default_commit_pragmas() {
String default_pragmas_str = sh(script: 'ci/gen_commit_pragmas.py --target origin/' + target_branch,
returnStdout: true).trim()
println('pragmas from gen_commit_pragmas.py:')
println(default_pragmas_str)
if (default_pragmas_str) {
updatePragmas(default_pragmas_str, false)
}
}
/**
* getScriptOutput
*
* Run a script and return the trimmed output.
*
* @param script the script to run
* @param args optional arguments to pass to the script
* @return the trimmed output from the script
*/
String getScriptOutput(String script, String args='') {
return sh(script: "${script} ${args}", returnStdout: true).trim()
}
/**
* scriptedBuildStage
*
* Get a build stage in scripted syntax.
*
* @param kwargs Map containing the following optional arguments (empty strings yield defaults):
* name the build stage name
* distro the shorthand distro name; defaults to 'el8'
* rpmDistro the distro to use for rpm building; defaults to distro
* compiler the compiler to use; defaults to 'gcc'
* runStage Optional additional condition to determine if the stage runs
* buildRpms whether or not to build rpms; defaults to true
* release the DAOS RPM release value to use; defaults to env.DAOS_RELVAL
* dockerBuildArgs optional docker build arguments
* sconsBuildArgs optional scons build arguments
* artifacts optional artifacts name to archive; defaults to
* "config.log-${distro}-${compiler}"
* uploadTarget the distro to use when uploading rpms; defaults to distro
* @return a scripted stage to run in a pipeline
*/
def scriptedBuildStage(Map kwargs = [:]) {
String name = kwargs.get('name', 'Unknown Build Stage')
String distro = kwargs.get('distro', 'el8')
String rpmDistro = kwargs.get('rpmDistro', distro)
String compiler = kwargs.get('compiler', 'gcc')
Boolean runStage = kwargs.get('runStage', true)
Boolean buildRpms = kwargs.get('buildRpms', true)
String release = kwargs.get('release', env.DAOS_RELVAL)
String dockerBuildArgs = kwargs.get('dockerBuildArgs', '')
Map sconsBuildArgs = kwargs.get('sconsBuildArgs', [:])
String artifacts = kwargs.get('artifacts', "config.log-${distro}-${compiler}")
String uploadTarget = kwargs.get('uploadTarget', distro)
String dockerTag = jobStatusKey("build-${uploadTarget}-${compiler}").toLowerCase()
String bullseye = 'false'
if (compiler == 'covc') {
bullseye = 'true'
}
return {
stage("${name}") {
if (!runStage) {
println("[${name}] Marking build stage as skipped")
Utils.markStageSkippedForConditional("${name}")
return
}
node('docker_runner') {
println("[${name}] Check out from version control")
checkoutScm(pruneStaleBranch: true)
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
try {
dockerImage.inside() {
if (buildRpms) {
sh label: 'Install RPMs',
script: "./ci/rpm/install_deps.sh ${rpmDistro} ${release} ${bullseye}"
// Avoid interpolation of sensitive environment variables
sh label: 'Build deps',
script: "./ci/rpm/build_deps.sh ${bullseye}" + ' ${BULLSEYE_KEY}'
}
job_step_update(sconsBuild(sconsBuildArgs))
if (buildRpms) {
sh label: 'Generate RPMs',
script: "./ci/rpm/gen_rpms.sh ${rpmDistro} ${release} ${bullseye}"
// Success actions
uploadNewRPMs(uploadTarget, 'success')
}
}
} catch (Exception e) {
// Unsuccessful actions
sh """if [ -f config.log ]; then
mv config.log ${artifacts}
fi"""
archiveArtifacts artifacts: "${artifacts}", allowEmptyArchive: true
throw e
} finally {
// Cleanup actions
if (buildRpms) {
uploadNewRPMs(uploadTarget, 'cleanup')
}
jobStatusUpdate(job_status_internal, name)
}
}
println("[${name}] Finished with ${job_status_internal}")
}
}
}
/**
* scriptedSummaryStage
*
* Get a summary stage in scripted syntax.
*
* @param kwargs Map containing the following optional arguments (empty strings yield defaults):
* name the summary stage name
* distro the shorthand distro name; defaults to 'el8'
* compiler the compiler to use; defaults to 'gcc'
* runStage Optional additional condition to determine if the stage runs
* dockerBuildArgs optional docker build arguments
* installScript optional script to install RPMs
* runScriptArgs Map of arguments to pass to runScriptWithStashes()
* archiveArtifactsArgs Map of arguments to pass to archiveArtifacts()
* publishHtmlArgs Map of arguments to pass to publishHTML()
* @return a scripted stage to run in a pipeline
*/
def scriptedSummaryStage(Map kwargs = [:]) {
String name = kwargs.get('name', 'Unknown Summary Stage')
String distro = kwargs.get('distro', 'el8')
String compiler = kwargs.get('compiler', 'gcc')
Boolean runStage = kwargs.get('runStage', true)
String dockerBuildArgs = kwargs.get('dockerBuildArgs', '')
String installScript = kwargs.get('installScript', '')
Map runScriptArgs = kwargs.get('runScriptArgs', [:])
Map archiveArtifactsArgs = kwargs.get('archiveArtifactsArgs', [:])
Map publishHtmlArgs = kwargs.get('publishHtmlArgs', [:])
String dockerTag = jobStatusKey("${name}-${distro}-${compiler}").toLowerCase()
return {
stage("${name}") {
if (!runStage) {
println("[${name}] Marking summary stage as skipped")
Utils.markStageSkippedForConditional("${name}")
return
}
node('docker_runner') {
println("[${name}] Check out from version control")
checkoutScm(pruneStaleBranch: true)
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
try {
dockerImage.inside() {
if (installScript) {
sh label: 'Install RPMs',
script: "${installScript} ${distro}"
}
job_step_update(runScriptWithStashes(runScriptArgs))
}
} finally {
// Cleanup actions
if (publishHtmlArgs) {
publishHTML(publishHtmlArgs)
}
if (archiveArtifactsArgs) {
archiveArtifacts(archiveArtifactsArgs)
}
jobStatusUpdate(job_status_internal, name)
}
}
println("[${name}] Finished with ${job_status_internal}")
}
}
}
// Determine if the Build with Bullseye was run and successful
Boolean bullseyeBuilt() {
Map status = job_status_internal['Build_on_EL_9_with_Bullseye'] ?: [:]
println("bullseyeBuilt: status=${status}, status.result=${status.result}")
return status.result == 'SUCCESS'
}
// Get the inst_rpms argument for the unitTest method
String unitTestInstRpms(String distro='el9', Boolean bullseye=false) {
return getScriptOutput("ci/unit/required_packages.sh ${distro} ${bullseye.toString()}")
}
// Get the compiler argument for the unitTest method
String unitTestCompiler(Boolean bullseye=false) {
if (bullseye) {
return 'covc'
}
return 'gcc'
}
// Get the packages to install for functional testing
String functionalInstRpms(String otherPackages, Boolean bullseye=false, String rpmDistro=null) {
String packages = functionalPackages(
clientVersion: 1,
nextVersion: next_version(),
addDaosPkgs: 'tests-internal',
rpmDistribution: rpmDistro)
if (bullseye) {
packages = packages.replace('daos', 'daos-bullseye')
packages += ' bullseye'
}
if (otherPackages) {
packages += " ${otherPackages}"
}
return packages
}
// Boolean skip_pragma_set(String name, String def_val='false') {
// // Return whether or not the skip pragma is set
// return cachedCommitPragma("Skip-${name}", def_val).toLowerCase() == 'true'
// }
// Boolean skip_build_stage(String distro='', String compiler='gcc') {
// // Skip the stage if the CI_<distro>_NOBUILD parameter is set
// if (distro) {
// if (startedByUser() && paramsValue("CI_${distro}_NOBUILD", false)) {
// println("[${env.STAGE_NAME}] Skipping build stage due to CI_${distro}_NOBUILD")
// return true
// }
// }
// // Skip the stage if any Skip-build[-<distro>-<compiler>] pragmas are true
// List<String> pragma_names = ['build']
// if (distro && compiler) {
// pragma_names << "build-${distro}-${compiler}"
// }
// Boolean any_pragma_skip = pragma_names.any { name ->
// if (skip_pragma_set(name)) {
// println("[${env.STAGE_NAME}] Skipping build stage due to \"Skip-${name}: true\" pragma")
// return true
// }
// }
// if (any_pragma_skip) {
// return true
// }
// // Skip the stage if a specific DAOS RPM version is specified
// if (rpmTestVersion() != '') {
// println("[${env.STAGE_NAME}] Skipping build stage for due to specific DAOS RPM version")
// return true
// }
// // Otherwise run the build stage
// return false
// }
pipeline {
agent { label 'lightweight' }
environment {
BULLSEYE_KEY = credentials('bullseye_license_key')
GITHUB_USER = credentials('daos-jenkins-review-posting')
SSH_KEY_ARGS = '-ici_key'
CLUSH_ARGS = "-o$SSH_KEY_ARGS"
TEST_RPMS = cachedCommitPragma(pragma: 'RPM-test', def_val: 'true')
COVFN_DISABLED = cachedCommitPragma(pragma: 'Skip-fnbullseye', def_val: 'true')
REPO_FILE_URL = repoFileUrl(env.REPO_FILE_URL)
SCONS_FAULTS_ARGS = sconsArgs()
HTTPS_PROXY = ''
PYTHON_VERSION = '3.11'
}
options {
// preserve stashes so that jobs can be started at the test stage
preserveStashes(buildCount: 5)
ansiColor('xterm')
buildDiscarder(logRotator(artifactDaysToKeepStr: '100', daysToKeepStr: '730'))
}
parameters {
string(name: 'BuildPriority',
/* groovylint-disable-next-line UnnecessaryGetter */
defaultValue: getPriority(),
description: 'Priority of this build. DO NOT USE WITHOUT PERMISSION.')
string(name: 'TestTag',
defaultValue: '',
description: 'Test-tag to use for this run (i.e. pr, daily_regression, full_regression, etc.)')
string(name: 'BuildType',
defaultValue: '',
description: 'Type of build. Passed to scons as BUILD_TYPE. (I.e. dev, release, debug, etc.). ' +
'Defaults to release on an RC or dev otherwise.')
string(name: 'TestRepeat',
defaultValue: '',
description: 'Test-repeat to use for this run. Specifies the ' +
'number of times to repeat each functional test. ' +
'CAUTION: only use in combination with a reduced ' +
'number of tests specified with the TestTag ' +
'parameter.')
string(name: 'TestProvider',
defaultValue: '',
description: 'Test-provider to use for the non-Provider Functional Hardware test ' +
'stages. Specifies the default provider to use the daos_server ' +
'config file when running functional tests (the launch.py ' +
'--provider argument; i.e. "ucx+dc_x", "ofi+verbs", "ofi+tcp")')
booleanParam(name: 'CI_BUILD_PACKAGES_ONLY',
defaultValue: false,
description: 'Build RPM and DEB packages, Skip unit tests.')
booleanParam(name: 'CI_ALLOW_UNSTABLE_TEST',
defaultValue: false,
description: 'Continue testing if a previous stage is Unstable')
booleanParam(name: 'CI_FULL_BULLSEYE_REPORT',
defaultValue: false,
description: 'Use this build to generate a full Bullseye code coverage report')
string(name: 'CI_SCONS_ARGS',
defaultValue: '',
description: 'Arguments for scons when building DAOS')
string(name: 'CI_RPM_TEST_VERSION',
defaultValue: '',
description: 'Package version to use instead of building. example: 1.3.103-1, 1.2-2')
// TODO: add parameter support for per-distro CI_PR_REPOS
string(name: 'CI_PR_REPOS',
defaultValue: '',
description: 'Additional repository used for locating packages for the build and ' +
'test nodes, in the project@PR-number[:build] format.')
string(name: 'CI_HARDWARE_DISTRO',
defaultValue: '',
description: 'Distribution to use for CI Hardware Tests')
string(name: 'CI_EL8_TARGET',
defaultValue: '',
description: 'Image to used for EL 8 CI tests. I.e. el8, el8.3, etc.')
string(name: 'CI_EL9_TARGET',
defaultValue: '',
description: 'Image to used for EL 9 CI tests. I.e. el9, el9.1, etc.')
string(name: 'CI_LEAP15_TARGET',
defaultValue: '',
description: 'Image to use for OpenSUSE Leap CI tests. I.e. leap15, leap15.2, etc.')
string(name: 'CI_UBUNTU20.04_TARGET',
defaultValue: '',
description: 'Image to used for Ubuntu 20 CI tests. I.e. ubuntu20.04, etc.')
booleanParam(name: 'Cancel Previous Builds',
defaultValue: true,
description: 'Run the Cancel Previous Builds stage.')
booleanParam(name: 'Pre-build',
defaultValue: true,
description: 'Run the pre-build stage.')
booleanParam(name: 'Python Bandit check',
defaultValue: true,
description: 'Run the Python Bandit check stage.')
booleanParam(name: 'Build',
defaultValue: true,
description: 'Run the build stage.')
booleanParam(name: 'Build on EL 8',
defaultValue: true,
description: 'Run the build on EL 8 stage.')
booleanParam(name: 'Build on EL 9',
defaultValue: true,
description: 'Run the build on EL 9 stage.')
booleanParam(name: 'Build on Leap 15',
defaultValue: true,
description: 'Run the build on Leap 15 stage.')
booleanParam(name: 'Build on EL 9 with Bullseye',
defaultValue: true,
description: 'Run the build on EL 9 with Bullseye stage.')
booleanParam(name: 'Unit Tests',
defaultValue: true,
description: 'Run the Unit Tests stage.')
booleanParam(name: 'Unit Test',
defaultValue: true,
description: 'Run the Unit Test stage.')
booleanParam(name: 'Unit Test bdev',
defaultValue: true,
description: 'Run the Unit Test bdev stage.')
booleanParam(name: 'NLT',
defaultValue: true,
description: 'Run the NLT stage.')
booleanParam(name: 'NLT with Bullseye',
defaultValue: true,
description: 'Run the NLT with Bullseye stage.')
booleanParam(name: 'Unit Test with memcheck',
defaultValue: true,
description: 'Run the Unit Test with memcheck stage.')
booleanParam(name: 'Unit Test bdev with memcheck',
defaultValue: true,
description: 'Run the Unit Test bdev with memcheck stage.')
booleanParam(name: 'Test',
defaultValue: true,
description: 'Run the Test stage.')
booleanParam(name: 'Functional on EL 8.8 with Valgrind',
defaultValue: false,
description: 'Run the Functional on EL 8.8 with Valgrind stage.')
booleanParam(name: 'Functional on EL 8',
defaultValue: false,
description: 'Run the Functional on EL 8 stage.')
booleanParam(name: 'Functional on EL 9',
defaultValue: true,
description: 'Run the Functional on EL 9 stage.')
booleanParam(name: 'Functional on Leap 15',
defaultValue: false,
description: 'Run the Functional on Leap 15 stage.')
booleanParam(name: 'Functional on SLES 15',
defaultValue: false,
description: 'Run the Functional on SLES 15 stage.')
booleanParam(name: 'Functional on Ubuntu 20.04',
defaultValue: false,
description: 'Run the Functional on Ubuntu 20.04 stage.')
booleanParam(name: 'Fault injection testing',
defaultValue: true,
description: 'Run the Fault injection testing stage.')
booleanParam(name: 'Test RPMs on EL 9.6',
defaultValue: true,
description: 'Run the Test RPMs on EL 9.6 stage.')
booleanParam(name: 'Test RPMs on Leap 15.5',
defaultValue: true,
description: 'Run the Test RPMs on Leap 15.5 stage.')
booleanParam(name: 'Test Hardware',
defaultValue: true,
description: 'Run the Test Hardware stage.')
booleanParam(name: 'Functional Hardware Medium',
defaultValue: false,
description: 'Run the Functional Hardware Medium stage.')
booleanParam(name: 'Functional Hardware Medium MD on SSD',
defaultValue: true,
description: 'Run the Functional Hardware Medium MD on SSD stage.')
booleanParam(name: 'Functional Hardware Medium VMD',
defaultValue: false,
description: 'Run the Functional Hardware Medium VMD stage.')
booleanParam(name: 'Functional Hardware Medium Verbs Provider',
defaultValue: false,
description: 'Run the Functional Hardware Medium Verbs Provider stage.')
booleanParam(name: 'Functional Hardware Medium Verbs Provider MD on SSD',
defaultValue: true,
description: 'Run the Functional Hardware Medium Verbs Provider MD on SSD stage.')
booleanParam(name: 'Functional Hardware Medium UCX Provider',
defaultValue: false,
description: 'Run the Functional Hardware Medium UCX Provider stage.')
booleanParam(name: 'Functional Hardware Large',
defaultValue: false,
description: 'Run the Functional Hardware Large stage.')
booleanParam(name: 'Functional Hardware Large MD on SSD',
defaultValue: true,
description: 'Run the Functional Hardware Large MD on SSD stage.')
string(name: 'CI_UNIT_VM1_LABEL',
defaultValue: 'ci_vm1',
description: 'Label to use for 1 VM node unit and RPM tests')
string(name: 'CI_UNIT_VM1_NVME_LABEL',
defaultValue: 'ci_ssd_vm1',
description: 'Label to use for 1 VM node unit tests that need NVMe')
string(name: 'FUNCTIONAL_VM_LABEL',
defaultValue: 'ci_vm9',
description: 'Label to use for 9 VM functional tests')
string(name: 'CI_NLT_1_LABEL',
defaultValue: 'ci_nlt_vm1',
description: 'Label to use for NLT tests')
string(name: 'CI_FI_1_LABEL',
defaultValue: 'ci_fi_vm1',
description: 'Label to use for Fault Injection (FI) tests')
string(name: 'FUNCTIONAL_HARDWARE_MEDIUM_LABEL',
defaultValue: 'ci_nvme5',
description: 'Label to use for the Functional Hardware Medium (MD on SSD) stages')
string(name: 'FUNCTIONAL_HARDWARE_MEDIUM_VERBS_PROVIDER_LABEL',
defaultValue: 'ci_ofed5',
description: 'Label to use for 5 node Functional Hardware Medium Verbs Provider (MD on SSD) stages')
string(name: 'FUNCTIONAL_HARDWARE_MEDIUM_VMD_LABEL',
defaultValue: 'ci_vmd5',
description: 'Label to use for the Functional Hardware Medium VMD stage')
string(name: 'FUNCTIONAL_HARDWARE_MEDIUM_UCX_PROVIDER_LABEL',
defaultValue: 'ci_ofed5',
description: 'Label to use for 5 node Functional Hardware Medium UCX Provider stage')
string(name: 'FUNCTIONAL_HARDWARE_LARGE_LABEL',
defaultValue: 'ci_nvme9',
description: 'Label to use for 9 node Functional Hardware Large (MD on SSD) stages')
string(name: 'CI_STORAGE_PREP_LABEL',
defaultValue: '',
description: 'Label for cluster to do a DAOS Storage Preparation')
string(name: 'CI_PROVISIONING_POOL',
defaultValue: '',
description: 'The pool of images to provision test nodes from')
string(name: 'CI_BUILD_DESCRIPTION',
defaultValue: '',
description: 'A description of the build')
}
stages {
stage('Prepare Environment Variables') {
// TODO: Could/should these be moved to the environment block?
parallel {
stage('Set Description') {
steps {
script {
if (params.CI_BUILD_DESCRIPTION) {
buildDescription params.CI_BUILD_DESCRIPTION
}
}
}
}
stage('Setup Stages') {
steps {
pragmasToEnv()
update_default_commit_pragmas()
updateRunStage()
}
}
stage('Get RPM relval') {
steps {
get_rpm_relval()
}
}
stage('Determine Release Branch') {
steps {
script {
env.RELEASE_BRANCH = releaseBranch()
echo 'Release branch == ' + env.RELEASE_BRANCH
}
}
}
}
}
stage('Check PR') {
when { changeRequest() }
parallel {
stage('Branch name check') {
when { changeRequest() }
steps {
script {
if (env.CHANGE_ID.toInteger() > 9742 && !env.CHANGE_BRANCH.contains('/')) {
error('Your PR branch name does not follow the rules. Please rename it ' +
'according to the rules described here: ' +
'https://daosio.atlassian.net/l/cp/UP1sPTvc#branch_names. ' +
'Once you have renamed your branch locally to match the ' +
'format, close this PR and open a new one using the newly renamed ' +
'local branch.')
}
}
}
}
} // parallel
} // stage('Check PR')
stage('Cancel Previous Builds') {
when {
beforeAgent true
expression { runStage['Cancel Previous Builds'] }
}
steps {
cancelPreviousBuilds()
}
}
stage('Pre-build') {
when {
beforeAgent true
expression { runStage['Pre-build'] }
}
parallel {
stage('Python Bandit check') {
when {