99
1010library '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
1323def 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,6 +153,7 @@ 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
@@ -241,6 +253,7 @@ def commonPrekladHarpRun(COMPONENTS, ofm_path = pwd()) {
241253 }
242254 }
243255 } catch(err) {
256+ propagateUserInterupt(err)
244257 currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
245258 failed.add("$name")
246259 } finally { // collect interesting files
@@ -392,6 +405,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
392405 sh "$command"
393406
394407 } catch (err) {
408+ propagateUserInterupt(err)
395409 echo "Error detected, firmware build failed!"
396410 currentBuild.result = 'FAILURE'
397411 currentStage.result = 'FAILURE'
@@ -405,6 +419,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
405419 sh "test -f results.xml"
406420 } catch (err) {
407421 echo "Error detected, no tests performed (results missing)!"
422+ propagateUserInterupt(err)
408423 currentBuild.result = 'FAILURE'
409424 currentStage.result = 'FAILURE'
410425 failed.add("$name")
@@ -413,6 +428,7 @@ def commonPrekladCocotbVerRun(COMPONENTS) {
413428 }
414429 }
415430 } catch(err) {
431+ propagateUserInterupt(err)
416432 currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
417433 failed.add("$name")
418434 } finally { // collect interesting files
@@ -460,44 +476,51 @@ def commonPrekladCocotbMultiVerRun(COMPONENTS, ofm_path = pwd()) {
460476
461477 def failed = []
462478
463- // run verification of every component
464- for(c in COMPONENTS) {
465- // parse
466- def name = c[0]
467- def path = c[1]
468- def settings = c[2]
469-
470- def multi_ver = "$ofm_path/build/scripts/multi_ver/multi_ver_cocotb.py"
471-
472- // exec vsim
473- try { // try-catch is a hack to continue even after the first failed verification
474- timeout(time: 4, unit: 'HOURS') {
475- stage("cocotb (MULTIVER): $name") {
476- dir("$path") {
477- try {
478- // run multi ver script for cocotb
479- def command = "python3 $multi_ver $settings"
480- sh "${print_info}"
481- sh "$command"
482-
483- } catch (err) {
484- echo "Error detected, firmware build failed!"
485- currentBuild.result = 'FAILURE'
486- currentStage.result = 'FAILURE'
487- 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+ }
488507 }
489508 }
490509 }
491- }
492- } catch(err) {
493- currentBuild.result = 'FAILURE' // still propagate failure status to Jenkins
494- failed.add("$name")
495- } finally { // collect interesting files
496- archiveArtifacts "$path/transcript" // verification log
497- if(currentBuild.result == "FAILURE") {
498- 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+ }
499519 }
500520 }
521+ } catch(err) {
522+ echo "Error:"
523+ echo err.toString()
501524 }
502525
503526 // send out emails if failure is detected
0 commit comments