Skip to content

Commit 629ced7

Browse files
committed
Replace runCondition
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
1 parent 615a57e commit 629ced7

1 file changed

Lines changed: 67 additions & 71 deletions

File tree

Jenkinsfile

Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,7 @@ String getScriptOutput(String script, String args='') {
480480
* distro the shorthand distro name; defaults to 'el8'
481481
* rpmDistro the distro to use for rpm building; defaults to distro
482482
* compiler the compiler to use; defaults to 'gcc'
483-
* runCondition optional additional condition to determine if the stage runs, used
484-
* in conjunction with runBuildStage(distro, compiler); defaults
485-
* to true
483+
* runStage Optional additional condition to determine if the stage runs
486484
* buildRpms whether or not to build rpms; defaults to true
487485
* release the DAOS RPM release value to use; defaults to env.DAOS_RELVAL
488486
* dockerBuildArgs optional docker build arguments
@@ -497,7 +495,7 @@ def scriptedBuildStage(Map kwargs = [:]) {
497495
String distro = kwargs.get('distro', 'el8')
498496
String rpmDistro = kwargs.get('rpmDistro', distro)
499497
String compiler = kwargs.get('compiler', 'gcc')
500-
Boolean runCondition = kwargs.get('runCondition', true)
498+
Boolean runStage = kwargs.get('runStage', true)
501499
Boolean buildRpms = kwargs.get('buildRpms', true)
502500
String release = kwargs.get('release', env.DAOS_RELVAL)
503501
String dockerBuildArgs = kwargs.get('dockerBuildArgs', '')
@@ -511,49 +509,48 @@ def scriptedBuildStage(Map kwargs = [:]) {
511509
}
512510
return {
513511
stage("${name}") {
514-
if (runBuildStage(distro, compiler, runCondition)) {
515-
node('docker_runner') {
516-
println("[${name}] Check out from version control")
517-
checkoutScm(pruneStaleBranch: true)
512+
if (!runStage) {
513+
println("[${name}] Marking build stage as skipped")
514+
Utils.markStageSkippedForConditional("${name}")
515+
return
516+
}
517+
node('docker_runner') {
518+
println("[${name}] Check out from version control")
519+
checkoutScm(pruneStaleBranch: true)
518520

519-
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
520-
try {
521-
dockerImage.inside() {
522-
if (buildRpms) {
523-
sh label: 'Install RPMs',
524-
script: "./ci/rpm/install_deps.sh ${rpmDistro} ${release} ${bullseye}"
525-
// Avoid interpolation of sensitive environment variables
526-
sh label: 'Build deps',
527-
script: "./ci/rpm/build_deps.sh ${bullseye}" + ' ${BULLSEYE_KEY}'
528-
}
529-
job_step_update(sconsBuild(sconsBuildArgs))
530-
if (buildRpms) {
531-
sh label: 'Generate RPMs',
532-
script: "./ci/rpm/gen_rpms.sh ${rpmDistro} ${release} ${bullseye}"
533-
// Success actions
534-
uploadNewRPMs(uploadTarget, 'success')
535-
}
521+
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
522+
try {
523+
dockerImage.inside() {
524+
if (buildRpms) {
525+
sh label: 'Install RPMs',
526+
script: "./ci/rpm/install_deps.sh ${rpmDistro} ${release} ${bullseye}"
527+
// Avoid interpolation of sensitive environment variables
528+
sh label: 'Build deps',
529+
script: "./ci/rpm/build_deps.sh ${bullseye}" + ' ${BULLSEYE_KEY}'
536530
}
537-
} catch (Exception e) {
538-
// Unsuccessful actions
539-
sh """if [ -f config.log ]; then
540-
mv config.log ${artifacts}
541-
fi"""
542-
archiveArtifacts artifacts: "${artifacts}", allowEmptyArchive: true
543-
throw e
544-
} finally {
545-
// Cleanup actions
531+
job_step_update(sconsBuild(sconsBuildArgs))
546532
if (buildRpms) {
547-
uploadNewRPMs(uploadTarget, 'cleanup')
533+
sh label: 'Generate RPMs',
534+
script: "./ci/rpm/gen_rpms.sh ${rpmDistro} ${release} ${bullseye}"
535+
// Success actions
536+
uploadNewRPMs(uploadTarget, 'success')
548537
}
549-
jobStatusUpdate(job_status_internal, name)
550538
}
539+
} catch (Exception e) {
540+
// Unsuccessful actions
541+
sh """if [ -f config.log ]; then
542+
mv config.log ${artifacts}
543+
fi"""
544+
archiveArtifacts artifacts: "${artifacts}", allowEmptyArchive: true
545+
throw e
546+
} finally {
547+
// Cleanup actions
548+
if (buildRpms) {
549+
uploadNewRPMs(uploadTarget, 'cleanup')
550+
}
551+
jobStatusUpdate(job_status_internal, name)
551552
}
552553
}
553-
else {
554-
println("[${name}] Marking build stage as skipped")
555-
Utils.markStageSkippedForConditional("${name}")
556-
}
557554
println("[${name}] Finished with ${job_status_internal}")
558555
}
559556
}
@@ -568,7 +565,7 @@ def scriptedBuildStage(Map kwargs = [:]) {
568565
* name the summary stage name
569566
* distro the shorthand distro name; defaults to 'el8'
570567
* compiler the compiler to use; defaults to 'gcc'
571-
* runCondition Optional additional condition to determine if the stage runs
568+
* runStage Optional additional condition to determine if the stage runs
572569
* dockerBuildArgs optional docker build arguments
573570
* installScript optional script to install RPMs
574571
* runScriptArgs Map of arguments to pass to runScriptWithStashes()
@@ -580,7 +577,7 @@ def scriptedSummaryStage(Map kwargs = [:]) {
580577
String name = kwargs.get('name', 'Unknown Summary Stage')
581578
String distro = kwargs.get('distro', 'el8')
582579
String compiler = kwargs.get('compiler', 'gcc')
583-
Boolean runCondition = kwargs.get('runCondition', true)
580+
Boolean runStage = kwargs.get('runStage', true)
584581
String dockerBuildArgs = kwargs.get('dockerBuildArgs', '')
585582
String installScript = kwargs.get('installScript', '')
586583
Map runScriptArgs = kwargs.get('runScriptArgs', [:])
@@ -590,36 +587,35 @@ def scriptedSummaryStage(Map kwargs = [:]) {
590587

591588
return {
592589
stage("${name}") {
593-
if (runCondition) {
594-
node('docker_runner') {
595-
println("[${name}] Check out from version control")
596-
checkoutScm(pruneStaleBranch: true)
590+
if (!runStage) {
591+
println("[${name}] Marking summary stage as skipped")
592+
Utils.markStageSkippedForConditional("${name}")
593+
return
594+
}
595+
node('docker_runner') {
596+
println("[${name}] Check out from version control")
597+
checkoutScm(pruneStaleBranch: true)
597598

598-
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
599-
try {
600-
dockerImage.inside() {
601-
if (installScript) {
602-
sh label: 'Install RPMs',
603-
script: "${installScript} ${distro}"
604-
}
605-
job_step_update(runScriptWithStashes(runScriptArgs))
606-
}
607-
} finally {
608-
// Cleanup actions
609-
if (publishHtmlArgs) {
610-
publishHTML(publishHtmlArgs)
611-
}
612-
if (archiveArtifactsArgs) {
613-
archiveArtifacts(archiveArtifactsArgs)
599+
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
600+
try {
601+
dockerImage.inside() {
602+
if (installScript) {
603+
sh label: 'Install RPMs',
604+
script: "${installScript} ${distro}"
614605
}
615-
jobStatusUpdate(job_status_internal, name)
606+
job_step_update(runScriptWithStashes(runScriptArgs))
616607
}
608+
} finally {
609+
// Cleanup actions
610+
if (publishHtmlArgs) {
611+
publishHTML(publishHtmlArgs)
612+
}
613+
if (archiveArtifactsArgs) {
614+
archiveArtifacts(archiveArtifactsArgs)
615+
}
616+
jobStatusUpdate(job_status_internal, name)
617617
}
618618
}
619-
else {
620-
println("[${name}] Marking summary stage as skipped")
621-
Utils.markStageSkippedForConditional("${name}")
622-
}
623619
println("[${name}] Finished with ${job_status_internal}")
624620
}
625621
}
@@ -1049,7 +1045,7 @@ pipeline {
10491045
name: 'Build on EL 8',
10501046
distro:'el8',
10511047
compiler: 'gcc',
1052-
runCondition: !paramsValue('CI_FULL_BULLSEYE_REPORT', false),
1048+
runStage: runStage['Build on EL 8'],
10531049
buildRpms: true,
10541050
release: env.DAOS_RELVAL,
10551051
dockerBuildArgs: dockerBuildArgs(repo_type: 'stable',
@@ -1074,7 +1070,7 @@ pipeline {
10741070
name: 'Build on EL 9',
10751071
distro:'el9',
10761072
compiler: 'gcc',
1077-
runCondition: !paramsValue('CI_FULL_BULLSEYE_REPORT', false),
1073+
runStage: runStage['Build on EL 9'],
10781074
buildRpms: true,
10791075
release: env.DAOS_RELVAL,
10801076
dockerBuildArgs: dockerBuildArgs(repo_type: 'stable',
@@ -1100,7 +1096,7 @@ pipeline {
11001096
distro:'leap15',
11011097
rpmDistro: 'suse.lp156',
11021098
compiler: 'gcc',
1103-
runCondition: !paramsValue('CI_FULL_BULLSEYE_REPORT', false),
1099+
runStage: runStage['Build on Leap 15'],
11041100
buildRpms: true,
11051101
release: env.DAOS_RELVAL,
11061102
dockerBuildArgs: dockerBuildArgs(repo_type: 'stable',
@@ -1765,7 +1761,7 @@ pipeline {
17651761
name: 'Bullseye Report',
17661762
distro: 'el9',
17671763
compiler: 'covc',
1768-
runCondition: runStage(['CI_BUILD_BULLSEYE': true]),
1764+
runStage: withBullseye(),
17691765
nodeLabel: 'docker_runner',
17701766
dockerBuildArgs: dockerBuildArgs(repo_type: 'stable',
17711767
deps_build: false,

0 commit comments

Comments
 (0)