The changes I have put in to support this are not in a release version of the 
buildflow - so you will need to download source and compile, or grab it from 
the Jenkins ci instance.

/James

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Åsmund Østvold
Sent: 28 October 2013 17:34
To: jenkinsci-users@googlegroups.com
Subject: Re: build flow, early exit from parallel construct?

Thank you James,

I finally freed up some time and was able do a new stab at this.  I have 
inlined some questions and feedback.

On Fri, Oct 25, 2013 at 6:33 AM, James Nord (jnord) 
<jn...@cisco.com<mailto:jn...@cisco.com>> wrote:
KillRunningjobs is called internally if the flow is aborted (or one of the jobs 
is aborted).
Internallyt this is handled by catching either  (IIRC) a JobAborteException (or 
also an IOException).

I did search for 10 minutes for "JobAborteException" or something close to 
this. But my Jenkins/Java knowledge is limite...

The IOException will show a stack trace in your console output - wheres the 
jobAbortEx will just show "Aborted" (and the cause if you set one),

I did try the blow but was not able to abort flow job. Job 'pass' takes 20s and 
job 'fail' taks only 5s:

parallel(
 {  b = build("pass");
    if (b.getResult() == Result.FAILURE) {
        throw new java.io.IOException("foo")
    } },
 {  b = build( "fail" );
    if (b.getResult() == Result.FAILURE) {
        throw new java.io.IOException("foo")
    }}
)

Console output:




parallel {

    Schedule job fail<http://ao:8080/job/fail/>

    Schedule job pass<http://ao:8080/job/pass/>

    Build fail #40<http://ao:8080/job/fail/40/> started

    Build pass #33<http://ao:8080/job/pass/33/> started

    fail #40<http://ao:8080/job/fail/40/> completed  : FAILURE

    pass #33<http://ao:8080/job/pass/33/> completed

}


I am probably doing something wrong but I am not able to see it. Any help would 
be appreciated.

So just throw one of those.  I guess I should add this to the extensions so you 
can just call ext.abortFlow("Reason") :)

With my limited understanding I believe this would be very good to have. If you 
add this could you consider adding something like:

  ext.failFlow("Reason")

It should do the same was for abortFlow("foo") but fail the build. For my use 
case this would "keep" the overall status as if all the jobs in the parallel 
section had finished. To also cover 'UNSTABLE' and 'SUCCESS' could the 
generalisation be exposing something like:

   terminateFlow(Result r, String s)

?

Also no need to check the string - check getResult() == Result.FAILURE or 
getResult().isWorseOrEqual(Result.FAILURE)

Thanks for this.

Asmund

--
dyslectic
--
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 
jenkinsci-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to