@@ -363,14 +363,29 @@ def build(command, cell) {
363363 def script_vars = " #!/bin/bash \n set -o pipefail ; " // pipe to tee needs pipefail
364364 script_vars = " ${ script_vars} m2_dir=\' ${ WORKSPACE} /build/m2\' "
365365 timeout(time : 1 , unit : ' HOURS' ) {
366- def status = sh label : " RUNNING ${ cell.step} ..." , script : " ${ script_vars} ${ build_script} ${ cell.jdk} 2>&1 | tee >( xz -c > build/${ logfile} )" , returnStatus : true
367- dir(" build" ) {
368- archiveArtifacts artifacts : " ${ logfile} " , fingerprint : true
369- copyToNightlies(" ${ logfile} " , " ${ cell.step} /jdk${ cell.jdk} /${ cell.arch} /" )
370- }
371- if (0 != status) { error(" Stage ${ cell.step}${ cell_suffix} failed with exit status ${ status} " ) }
372- if (" jar" == cell. step) {
373- stash name : " ${ cell.arch} _${ cell.jdk} "
366+ try {
367+ def status = sh label : " RUNNING ${ cell.step} ..." , script : " ${ script_vars} ${ build_script} ${ cell.jdk} 2>&1 | tee >( xz -c > build/${ logfile} )" , returnStatus : true
368+ dir(" build" ) {
369+ archiveArtifacts artifacts : " ${ logfile} " , fingerprint : true
370+ copyToNightlies(" ${ logfile} " , " ${ cell.step} /jdk${ cell.jdk} /${ cell.arch} /" )
371+ }
372+ if (0 != status) { error(" Stage ${ cell.step}${ cell_suffix} failed with exit status ${ status} " ) }
373+ if (" jar" == cell. step) {
374+ stash name : " ${ cell.arch} _${ cell.jdk} "
375+ }
376+ } catch (exc) {
377+ if (" org.jenkinsci.plugins.workflow.steps.FlowInterruptedException" == exc. getClass(). getName()) {
378+ def descriptions = []
379+ for (def cause in exc. getCauses()) {
380+ echo " CauseOfInterruption: ${ cause.getClass().getName()} - ${ cause.getShortDescription()} "
381+ if (cause. getClass(). getName(). contains(' CauseOfInterruption$UserInterruption' )) {
382+ throw exc // user explicitly aborted — do not retry
383+ }
384+ descriptions. add(cause. getShortDescription())
385+ }
386+ error(" Retryable interruption: ${ descriptions.join(', ')} " )
387+ }
388+ throw exc
374389 }
375390 }
376391 dir(" build" ) {
@@ -417,10 +432,16 @@ def test(command, cell) {
417432 }
418433 if (0 != status) { error(" Stage ${ cell.step}${ cell_suffix} failed with exit status ${ status} " ) }
419434 } catch (exc) {
420- if (exc. getClass(). getName() == " org.jenkinsci.plugins.workflow.steps.FlowInterruptedException" ) {
421- for (def causeOfInterruption in exc. getCauses()) {
422- echo " CauseOfInterruption: ${ causeOfInterruption.getClass().getName()} - ${ causeOfInterruption.getShortDescription()} "
435+ if (" org.jenkinsci.plugins.workflow.steps.FlowInterruptedException" == exc. getClass(). getName()) {
436+ def descriptions = []
437+ for (def cause in exc. getCauses()) {
438+ echo " CauseOfInterruption: ${ cause.getClass().getName()} - ${ cause.getShortDescription()} "
439+ if (cause. getClass(). getName(). contains(' CauseOfInterruption$UserInterruption' )) {
440+ throw exc // user explicitly aborted — do not retry
441+ }
442+ descriptions. add(cause. getShortDescription())
423443 }
444+ error(" Retryable interruption: ${ descriptions.join(', ')} " )
424445 }
425446 throw exc
426447 } finally {
0 commit comments