Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can you stop a pipeline from a script step?

ericjansen82 February 11, 2020

Can I stop an entire pipeline from a script in a step without having it fail?

 

In our case we have multiple triggers for a pipeline, but it only has to run in a specific case, when all other processes have finished. 

 

I would like to stop all other steps if the check fails in the first step without failing the pipeline, because this is a known stop and therefore should not trigger a failed status.

 

My current alternative is to do the check on the start of each step, which works, but does not indicate stoped in the overview of the pipeline and is inefficient. 

 

Hope someone can help!

Thanks in advance.

2 answers

2 votes
Dennis Andersen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2020

I would also be interested in a solution to this. Currently I've worked around it by merging my steps in a single script that does the initial check. If conditions aren't met it simply exits. Otherwise it continues calling each subsequent step scripts.

The downside is that from the UI I only get the 1 step without being able to really trace individual steps or configuring them separately with size, cache max-time etc.

Dennis Andersen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2020

Hi again!
As an update I just want to mention that in the end, I reverted the solution mentioned above to instead pass data between my steps using artifacts as per https://community.atlassian.com/t5/Bitbucket-questions/Is-there-a-way-of-sharing-data-between-steps-in-bitbucket/qaq-p/777977

In my conditional step I do the needed checks and store the result in an artifact e.g. "runTests". Then in the subsequent steps I check for if that artifact exists before continuing with the step. If it doesn't the step script is completed without having to fail. 

It's not optimal as you also point out, in that you still have the step boot up overhead but it's the only solution I've found so far. 

Like Hamza Haidar likes this
Eric Jansen May 17, 2020

Thanks, that's our current solution as well, but still multiple steps are started and build minutes are used.

Truly hope Atlassian reads this.

0 votes
Deleted user September 21, 2020

Run into this problem as well, also ended up using artifacts.

 

It is also possible to use non-zero exit codes, like `exit 1;` - and the whole pipeline would fail, but ofc that's not always the preferred behavior.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events