You want to do something like :

try {
        currentBuild.result = "SUCCESS"
        //do your stuff, stages etc.
} catch (err) {
        currentBuild.result = "FAILURE"
        throw err
}

(Of course you’ll have to adjust this to your needs)

This way the build will be green if all the stages are green and it will be red 
if a stage fails.

Is this what you’re looking for ?


> Le 21 juil. 2016 à 12:17, [email protected] a écrit :
> 
> When I do this ... currentBuild.result = "FAILURE" for a small test pipeline 
> job then the build fails also the stages are green.
> Exactly the problem I explained. When setting to "SUCCESS" all is fine. So 
> obvious there is anything adjusting the state wrongly.
> 
> Is there a way where I can check the success state after each operation?
> (as mentioned ... echo currentBuild.result prints null)
> 
> On Thursday, July 21, 2016 at 12:07:43 PM UTC+2, [email protected] 
> <http://teamaol.com/> wrote:
> Will give it a try ...
> 
> On Thursday, July 21, 2016 at 12:00:15 PM UTC+2, Thomas Zoratto wrote:
> currentBuild.result is writable
> 
> try to set it to 'SUCCESS' when before your pipeline reaches the end
> 
>> Le 21 juil. 2016 à 11:53, [email protected] <> a écrit :
>> 
>> We are working with Jenkins 2.13 the moment.
>> We have a ci/cd pipeline with all stages green but the build itself is red.
>> 
>> From the log I cannot see anything which gives me a hint.
>> Also all deployed stuff is fine and the final slack notification were also 
>> fine!
>> 
>> Every "sh" call is wrapped by the try ... catch ... throw ... so if there 
>> would
>> be an error the pipeline should stop at the stage where the error appears.
>> 
>> I wrote manually a jenkinsfile but ... as you can guess ... all fine.
>> 
>> I didn't found a way to check the build state. When is this set?
>> Can I do an echo of current state so I could add some output?
>> 
>> currentBuild.result prints null, so obviously this is not used.
>> Any help, proposes?
>> 
>> Kind regards,
>> Thomas
>> 
>> -- 
>> 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] <>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/13fa2d82-4e53-40df-a9a6-d6d2f020b2b7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/13fa2d82-4e53-40df-a9a6-d6d2f020b2b7%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/5393aca6-eee1-4832-9dce-3052781a6010%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/5393aca6-eee1-4832-9dce-3052781a6010%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0744AC69-CC6E-4B85-90DE-C4AAF7F29368%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to