Hobby
There is an error in the code you posted...
build("Failure_Clean"])
should be:
build("Failure_Clean")
When I corrected the error it worked as expected for me.
You could add specific cleanups like this:
def b
guard {
b=build("JobA")
} rescue {
if (b.result == SUCCESS) {
build("Normal_Clean")
}
else if (b.result == UNSTABLE {
build("Unstable_Clean")
}
else if (b.result == FAILURE {
build("Failure_Clean")
}
else if (b.result == ABORTED {
build("Aborted_Clean")
}
// I think there are only 4 result options, but in case there are more.
else {
build("Some_Other_Clean")
}
}
--
James
On 13 March 2014 07:17, Hobby Tan <[email protected]> wrote:
> Hi James,
> But if I cancel the "JobA" from Jenkins, it will STILL call
> build("Normal_Clean").
> So is there any other judgment I can use to handle the "Cancel" action from
> Jenkins?
>
> Thanks,
>
> Hobby
>
> -----Original Message-----
> From: Hobby Tan
> Sent: Thursday, March 13, 2014 12:45 PM
> To: [email protected]
> Subject: RE: [Build Flow Plugin] how to execute different rescue when job
> failed in guard
>
> Thanks James for your comments
>
> I try the following which is little different from your comment, and it can
> work now.
>
> def b
> def guard_result =FAILURE
> guard{
> b=build("JobA")
> } rescue {
> guard_result = b.result
> if (guard_result == SUCCESS)
> {
> build("Normal_Clean")
> }else
> {
> build("Failure_Clean"])
> }
> }
>
> Hobby
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of James Chapman
> Sent: Wednesday, March 12, 2014 8:01 PM
> To: [email protected]
> Subject: Re: [Build Flow Plugin] how to execute different rescue when job
> failed in guard
>
> You can use some groovy code instead... (Which probably isn't officially
> supported and might stop working in the future?)
>
>
>
> def resultA
> ignore(FAILURE) {
> build( "JobA" )
> resultA = build.state.result
> }
>
> if (resultA == SUCCESS) {
> build( "normal_clean" )
> } else {
> build( "failed_clean" )
> }
>
>
> --
> James
>
> On 12 March 2014 06:50, Hobby Tan <[email protected]> wrote:
>> Anyone has idea for this ??
>>
>> Thanks,
>>
>>
>>
>> Hobby
>>
>>
>>
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> Sent: Tuesday, March 11, 2014 12:31 AM
>> To: [email protected]
>> Subject: [Build Flow Plugin] how to execute different rescue when job
>> failed in guard
>>
>>
>>
>> I want to execute different rescue based on job was failed or not in
>> guard as below:
>>
>>
>>
>>
>>
>> guard{
>>
>>
>>
>> build("JobA")
>>
>> build("JobB")
>>
>>
>>
>> }rescue{
>>
>>
>>
>> if JobA or JobB failed
>>
>> failed clean
>>
>> else
>>
>> normal clean
>>
>> }
>>
>>
>>
>>
>>
>> --
>> 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].
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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].
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.
--
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].
For more options, visit https://groups.google.com/d/optout.