Re: build flow, early exit from parallel construct?

2013-11-03 Thread teilo
Take a look at src/test/groovy/com/cloudbees/plugins/flow/AbortTest.groovy 
 - this should say that it is possible to do what you want :-)


On Tuesday, 29 October 2013 02:43:19 UTC-4, asmundo wrote:
>
> On Tue, Oct 29, 2013 at 4:16 AM, James Nord (jnord) 
> 
> > wrote:
>
>>  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.
>>
>
> I forgot to state that I am did this. Sorry about that.  I am running:
>
>* 305af7f Merge pull request #37 from mattiasbpersson/master 
>* build-flow-plugin:0.11-SNAPSHOT
>
> I did very much like the groovy shell evaluation!
>
> Asmund
>
>
>
>
>  
>>
> 
>>
>> ** **
>>
>> /James
>>
>> ** **
>>   
>> *From:* jenkins...@googlegroups.com  [mailto:
>> jenkins...@googlegroups.com ] *On Behalf Of *Åsmund Østvold
>> *Sent:* 28 October 2013 17:34
>>
>> *To:* jenkins...@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) 
>> > 
>> 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”) J
>>  
>>  ** **
>>  
>> 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-use...@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-use...@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.


Re: build flow, early exit from parallel construct?

2013-10-28 Thread Åsmund Østvold
On Tue, Oct 29, 2013 at 4:16 AM, James Nord (jnord)  wrote:

>  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.
>

I forgot to state that I am did this. Sorry about that.  I am running:

   * 305af7f Merge pull request #37 from mattiasbpersson/master
   * build-flow-plugin:0.11-SNAPSHOT

I did very much like the groovy shell evaluation!

Asmund





>

>
> ** **
>
> /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) 
> 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”) J
>
>  ** **
>
> 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.
> 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.
>

-- 
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.


RE: build flow, early exit from parallel construct?

2013-10-28 Thread James Nord (jnord)
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) 
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.


Re: build flow, early exit from parallel construct?

2013-10-28 Thread Åsmund Østvold
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)  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 
Schedule job pass 
Build fail #40  started

Build pass #33  started

fail #40  completed  : FAILURE

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”) J
>

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.
For more options, visit https://groups.google.com/groups/opt_out.


RE: build flow, early exit from parallel construct?

2013-10-24 Thread James Nord (jnord)
Hi Åsmund ,

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).
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),
So just throw one of those.  I guess I should add this to the extensions so you 
can just call ext.abortFlow("Reason") :)

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

/James

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

thank you James,

I will have a look at the new code tomorrow.

What I have now is:
parallel(
 {  b = build("pass");
if (b.getResult().toString() == "FAILURE") {
build.doStop();
}},
 {  b = build( "fail" );
if (b.getResult().toString() == "FAILURE") {
build.doStop();
}}
)

What I think I would like to be able to call is:

 private void killRunningJobs(FlowRun flowRun, BuildListener listener)

Asmund



On Thu, Oct 24, 2013 at 9:55 PM, James Nord (jnord) 
mailto:jn...@cisco.com>> wrote:
I think I made some changes in the code that may be able to help with this by 
chaining the abort to the rest of the build.

If you combine this with some groovy to abort the build (by throwing the 
relavant exception) then the jobs in progress should be aborted.

You will need to get the latest code and build it.

As always there may be other ways to achieve the same thing.

Regards,

/James

From: jenkinsci-users@googlegroups.com<mailto:jenkinsci-users@googlegroups.com> 
[mailto:jenkinsci-users@googlegroups.com<mailto:jenkinsci-users@googlegroups.com>]
 On Behalf Of Åsmund Østvold
Sent: 24 October 2013 08:22
To: jenkinsci-users@googlegroups.com<mailto:jenkinsci-users@googlegroups.com>
Subject: build flow, early exit from parallel construct?

Build Flow Plugin very useful plugging.

Is it possible to get the parallel construct to "terminate" still executing 
jobs at first job exiting with none success? Or at least early fail the 
job/section containing the parallel construct.

Use case is that I have a total long(30min) check-in regression test time. Some 
tests finishes in 2 min some take 30 min. Because of early feedback and 
resources issues I would like to fail a change as early as possible.

Asmund

--
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<mailto:jenkinsci-users%2bunsubscr...@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<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.


Re: build flow, early exit from parallel construct?

2013-10-24 Thread Åsmund Østvold
thank you James,

I will have a look at the new code tomorrow.

What I have now is:

parallel(
 {  b = build("pass");
if (b.getResult().toString() == "FAILURE") {
build.doStop();
}},
 {  b = build( "fail" );
if (b.getResult().toString() == "FAILURE") {
build.doStop();
}}
)

What I think I would like to be able to call is:

 private void killRunningJobs(FlowRun flowRun, BuildListener listener)

Asmund




On Thu, Oct 24, 2013 at 9:55 PM, James Nord (jnord)  wrote:

>  I think I made some changes in the code that may be able to help with
> this by chaining the abort to the rest of the build.
>
> ** **
>
> If you combine this with some groovy to abort the build (by throwing the
> relavant exception) then the jobs in progress should be aborted.
>
> ** **
>
> You will need to get the latest code and build it.
>
> ** **
>
> As always there may be other ways to achieve the same thing.
>
> ** **
>
> Regards,
>
> ** **
>
> /James
>
> ** **
>
> *From:* jenkinsci-users@googlegroups.com [mailto:
> jenkinsci-users@googlegroups.com] *On Behalf Of *Åsmund Østvold
> *Sent:* 24 October 2013 08:22
> *To:* jenkinsci-users@googlegroups.com
> *Subject:* build flow, early exit from parallel construct?
>
> ** **
>
> Build Flow Plugin very useful plugging.  
>
> ** **
>
> Is it possible to get the parallel construct to "terminate" still
> executing jobs at first job exiting with none success? Or at least early
> fail the job/section containing the parallel construct. 
>
> ** **
>
> Use case is that I have a total long(30min) check-in regression test time.
> Some tests finishes in 2 min some take 30 min. Because of early feedback
> and resources issues I would like to fail a change as early as possible.**
> **
>
> ** **
>
> Asmund
>
> ** **
>
> --
> 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.
>
> --
> 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.
>

-- 
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.


RE: build flow, early exit from parallel construct?

2013-10-24 Thread James Nord (jnord)
I think I made some changes in the code that may be able to help with this by 
chaining the abort to the rest of the build.

If you combine this with some groovy to abort the build (by throwing the 
relavant exception) then the jobs in progress should be aborted.

You will need to get the latest code and build it.

As always there may be other ways to achieve the same thing.

Regards,

/James

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

Build Flow Plugin very useful plugging.

Is it possible to get the parallel construct to "terminate" still executing 
jobs at first job exiting with none success? Or at least early fail the 
job/section containing the parallel construct.

Use case is that I have a total long(30min) check-in regression test time. Some 
tests finishes in 2 min some take 30 min. Because of early feedback and 
resources issues I would like to fail a change as early as possible.

Asmund

--
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.

-- 
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.