# Build result in scripted pipeline

**URL:** <https://community.jenkins.io/t/build-result-in-scripted-pipeline/1476>\
**Category:** Ask a question\
**Created:** [February 9, 2022, 7:58am UTC](https://community.jenkins.io/t/build-result-in-scripted-pipeline/1476 "2022-02-09T07:58:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OsFr](https://avatars.discourse-cdn.com/v4/letter/o/ecccb3/32.png) [@OsFr](https://community.jenkins.io/u/OsFr)\
**Post date:** [February 9, 2022, 7:58am UTC](https://community.jenkins.io/t/build-result-in-scripted-pipeline/1476/1 "2022-02-09T07:58:18Z")

</div>

Hi All,

I have pipeline, defined in SCM.  
I am trying to perform some actions in case the build failed.  
To perform it I added try-catch-finally block. In the catch block I mark the currentBuild.result as “FAILURE”, and in the Finally, I check the currentBuild.result and perform my actions.  
The pipeline contains some downstream jobs. when one of the sub job is aborted, exception is thrown and the build marked as FAILURE.  
I don’t want the actions of failures to invoked in this case. what can I do?

Thanks.

---

<div class="post-metadata">

**Author:** ![OsFr](https://avatars.discourse-cdn.com/v4/letter/o/ecccb3/32.png) [@OsFr](https://community.jenkins.io/u/OsFr)\
**Post date:** [February 9, 2022, 9:02am UTC](https://community.jenkins.io/t/build-result-in-scripted-pipeline/1476/2 "2022-02-09T09:02:52Z")

</div>

I found a way:  
use the filed result in org.jenkinsci.plugins.workflow.steps.FlowInterruptedException.  
like this:

> catch (exception) {  
> if (exception instanceof org.jenkinsci.plugins.workflow.steps.FlowInterruptedException){  
> currentBuild.result = exception.result  
> }  
> }
