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
[Pipeline] [success_1] build (Building successjob)
[success_1] Scheduling project: successjob
[Pipeline] [fail_2] build (Building failurejob2)
[fail_2] Scheduling project: failurejob2
[success_1] Starting building: successjob #7
[fail_2] Starting building: failurejob2 #3
[fail_1] Starting building: failurejob #7
[Pipeline] } //parallel
[Pipeline] } //parallel
[Pipeline] } //parallel
[Pipeline] Execute in parallel : End
[Pipeline] echo
Caught the exception
[Pipeline] echo
fail_2
[Pipeline] End of Pipeline
Finished: 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?