Skip to content

Commit 1c8f44f

Browse files
committed
Merge branch 'vodak-fix-jenkins-code-coverage' into 'devel'
fix(jenkins): don't throw an exception when a coverage report fails See merge request ndk/ndk-fpga!291
2 parents 386232c + 61626de commit 1c8f44f

File tree

1 file changed

+61
-34
lines changed

1 file changed

+61
-34
lines changed

tests/jenkins/common.jenkins

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99

1010
library 'liberouter'
1111

12+
13+
def propagateUserInterupt(err) {
14+
if (err.getClass() == org.jenkinsci.plugins.workflow.steps.FlowInterruptedException) {
15+
echo "Detected exception: ${err.toString()}, proceeding to end the whole job..."
16+
throw err
17+
} else {
18+
echo "Detected exception: ${err.toString()}"
19+
}
20+
}
21+
1222
// Jenkins configuration for multiple modules
1323
def commonPrekladVerRun(COMPONENTS) {
1424

@@ -52,6 +62,7 @@ def commonPrekladVerRun(COMPONENTS) {
5262
}
5363
}
5464
} catch(err) {
65+
propagateUserInterupt(err)
5566
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
5667
failed.add("$name")
5768
} finally { // collect interesting files
@@ -142,13 +153,18 @@ def commonPrekladMultiVerRun(COMPONENTS, ofm_path = pwd()) {
142153
}
143154
}
144155
} catch(err) {
156+
propagateUserInterupt(err)
145157
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
146158
failed.add("$name")
147159
} finally { // collect interesting files
148160
archiveArtifacts "$path/transcript*" // verification log
149161
if (run_coverage_report) {
150162
// Generate a coverage report file
151-
sh "python3 ${coverage_reporter} --name \"$name\" --input \"$path/coverage_merged.ucdb\" --output \"$path/coverage_report.json\""
163+
sh(
164+
script: "python3 ${coverage_reporter} --name \"$name\" --input \"$path/coverage_merged.ucdb\" --output \"$path/coverage_report.json\"",
165+
returnStatus: true,
166+
returnStdout: false,
167+
)
152168
}
153169
if(currentBuild.result == "FAILURE") {
154170
archiveArtifacts "$path/vsim.wlf" // generated waveform, use vsim -view vsim.wlf
@@ -237,6 +253,7 @@ def commonPrekladHarpRun(COMPONENTS, ofm_path = pwd()) {
237253
}
238254
}
239255
} catch(err) {
256+
propagateUserInterupt(err)
240257
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
241258
failed.add("$name")
242259
} finally { // collect interesting files
@@ -388,6 +405,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
388405
sh "$command"
389406

390407
} catch (err) {
408+
propagateUserInterupt(err)
391409
echo "Error detected, firmware build failed!"
392410
currentBuild.result = 'FAILURE'
393411
currentStage.result = 'FAILURE'
@@ -401,6 +419,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
401419
sh "test -f results.xml"
402420
} catch (err) {
403421
echo "Error detected, no tests performed (results missing)!"
422+
propagateUserInterupt(err)
404423
currentBuild.result = 'FAILURE'
405424
currentStage.result = 'FAILURE'
406425
failed.add("$name")
@@ -409,6 +428,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
409428
}
410429
}
411430
} catch(err) {
431+
propagateUserInterupt(err)
412432
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
413433
failed.add("$name")
414434
} finally { // collect interesting files
@@ -456,44 +476,51 @@ def commonPrekladCocotbMultiVerRun(COMPONENTS, ofm_path = pwd()) {
456476

457477
def failed = []
458478

459-
// run verification of every component
460-
for(c in COMPONENTS) {
461-
// parse
462-
def name = c[0]
463-
def path = c[1]
464-
def settings = c[2]
465-
466-
def multi_ver = "$ofm_path/build/scripts/multi_ver/multi_ver_cocotb.py"
467-
468-
// exec vsim
469-
try { // try-catch is a hack to continue even after the first failed verification
470-
timeout(time: 4, unit: 'HOURS') {
471-
stage("cocotb (MULTIVER): $name") {
472-
dir("$path") {
473-
try {
474-
// run multi ver script for cocotb
475-
def command = "python3 $multi_ver $settings"
476-
sh "${print_info}"
477-
sh "$command"
478-
479-
} catch (err) {
480-
echo "Error detected, firmware build failed!"
481-
currentBuild.result = 'FAILURE'
482-
currentStage.result = 'FAILURE'
483-
failed.add("$name")
479+
try {
480+
// run verification of every component
481+
for(c in COMPONENTS) {
482+
// parse
483+
def name = c[0]
484+
def path = c[1]
485+
def settings = c[2]
486+
487+
def multi_ver = "$ofm_path/build/scripts/multi_ver/multi_ver_cocotb.py"
488+
489+
// exec vsim
490+
try { // try-catch is a hack to continue even after the first failed verification
491+
timeout(time: 4, unit: 'HOURS') {
492+
stage("cocotb (MULTIVER): $name") {
493+
dir("$path") {
494+
try {
495+
// run multi ver script for cocotb
496+
def command = "python3 $multi_ver $settings"
497+
sh "${print_info}"
498+
sh "$command"
499+
500+
} catch (err) {
501+
propagateUserInterupt(err)
502+
echo "Error detected, firmware build failed!"
503+
currentBuild.result = 'FAILURE'
504+
currentStage.result = 'FAILURE'
505+
failed.add("$name")
506+
}
484507
}
485508
}
486509
}
487-
}
488-
} catch(err) {
489-
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
490-
failed.add("$name")
491-
} finally { // collect interesting files
492-
archiveArtifacts "$path/transcript" // verification log
493-
if(currentBuild.result == "FAILURE") {
494-
archiveArtifacts "$path/vsim.wlf" // generated waveform, use vsim -view vsim.wlf
510+
} catch(err) {
511+
propagateUserInterupt(err)
512+
currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
513+
failed.add("$name")
514+
} finally { // collect interesting files
515+
archiveArtifacts "$path/transcript" // verification log
516+
if(currentBuild.result == "FAILURE") {
517+
archiveArtifacts "$path/vsim.wlf" // generated waveform, use vsim -view vsim.wlf
518+
}
495519
}
496520
}
521+
} catch(err) {
522+
echo "Error:"
523+
echo err.toString()
497524
}
498525

499526
// send out emails if failure is detected

0 commit comments

Comments
 (0)