When I run jobs in parallel, the Build Flow fails or passes as I’d expect. Example:
parallel (
{ build(job1) },
{ build(job2) },
{ build(job3) },
)
All of the jobs are started and if they all pass, the Build Flow passes. If
one fails, the Build Flow fails.
What I’d like to do is to run jobs sequentially, ignoring a failure *for that
moment* but at the end, fail or pass the Build Flow as a whole. Using
“ignore(FAILURE)" doesn’t give me what I want because it will ignore a failure
and pass the Build Flow regardless:
ignore(FAILURE) {build(job1)}
ignore(FAILURE) {build(job2)}
ignore(FAILURE) {build(job3)}
If they all fail, the Build Flow still passes because failures are ignored.
But I really need ALL of the jobs to run no matter the outcome of the other
jobs, and the Build Flow to pass/fail, depending on each outcome.
Therefore, I have tried something like this (which I thought I got to actually
work at one point but I can’t get it to work again!?! The closest I can get is
explained further down.):
FailuresPresent = 0;
try {
build(job1)
}catch(e) {
FailuresPresent = FailuresPresent++;
}
try {
build(job2)
}catch(e) {
FailuresPresent = FailuresPresent++;
}
try {
build(job3)
}catch(e) {
FailuresPresent = FailuresPresent++;
}
if ( FailuresPresent>0) {
println(“There were “+FailuresPresent+" test(s) that failed”);
throw new Exception("FAILED!”);
}else {
println "Tests PASSED!";
}
But the Build Flow will still stop immediately after a failed job (I don’t see
my println at the end). If I use an ignore(FAILURE) wrapper, then the “catch”
is ignored and the Build Flow passes.
I am not using guard/rescue because I don’t need the FailuresPresent to
increment every time, only when there is a failure (or do I? Guard/Rescue is
like try/finally, not a try/catch.)
None of my jobs are dependent on another, I just want them all grouped together
and to run sequentially in a single Build Flow if possible. Running them in
parallel maxes out my resources (not Jenkins but my Selenium hub).
If I wrap the above jobs in a parallel statement, it seems to gives the
appearance of it finishing to completion (my print statement at the end is
seen) but the Build Flow doesn’t run the other jobs.
This is the output with the entire try/catch/builds wrapped in a parallel
statement (notice job2 and job3 aren’t run but my println at the end is seen:
parallel {
Schedule job job1
Build job1 #34 started
job1 #34 completed : UNSTABLE
}
There were 0 test(s) that failed
Tests PASSED!
Suggestions? I hope I’m over-thinking this.
Thanks.
smime.p7s
Description: S/MIME cryptographic signature
