I'm using parallel in a pipeline, and want to be able to identify which 
threads are failing when there's a failure.  Since parallel doesn't return 
anything useful for this, I'm trying to catch the exceptions in a try/catch 
block, but no matter how many failures I have, I only ever seem to get a 
single exception.  Here's an example (failurejob and failurejob2 are just 
freestyle jobs that run /bin/false, while successjob runs /bin/true):

def nodes = [:]
nodes['fail_1'] = {
    build job: 'failurejob'
}
nodes['success_1'] = {
    build job: 'successjob'
}
nodes['fail_2'] = {
    build job: 'failurejob2'
}

try {
    parallel nodes
} catch(org.jenkinsci.plugins.workflow.cps.steps.ParallelStepException ex) {
    print "Caught the exception\n"
    print ex.name
}

And here's the output:

[Pipeline] Execute in parallel : Start[Pipeline] [fail_1] parallel { (Branch: 
fail_1)[Pipeline] [success_1] parallel { (Branch: success_1)[Pipeline] [fail_2] 
parallel { (Branch: fail_2)[Pipeline] [fail_1] build (Building 
failurejob)[fail_1] Scheduling project: failurejob 
<http://jenkins.gigamon.com/job/failurejob/>[Pipeline] [success_1] build 
(Building successjob)[success_1] Scheduling project: successjob 
<http://jenkins.gigamon.com/job/successjob/>[Pipeline] [fail_2] build (Building 
failurejob2)[fail_2] Scheduling project: failurejob2 
<http://jenkins.gigamon.com/job/failurejob2/>

[success_1] Starting building: successjob #7 
<http://jenkins.gigamon.com/job/successjob/7/>
[fail_2] Starting building: failurejob2 #3 
<http://jenkins.gigamon.com/job/failurejob2/3/>
[fail_1] Starting building: failurejob #7 
<http://jenkins.gigamon.com/job/failurejob/7/>

[Pipeline] } //parallel[Pipeline] } //parallel[Pipeline] } //parallel[Pipeline] 
Execute in parallel : End[Pipeline] echoCaught the exception
[Pipeline] echofail_2[Pipeline] End of PipelineFinished: SUCCESS



fail_1 and fail_2 both failed, but I only saw an exception for fail_2.  
Why?  Is there some way to get both exceptions?

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/59f31e6c-54dc-41b3-8fb3-439183bc7342%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to