The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using BitBucket Pipelines, can you trigger a step when it fails?

Michael J Love
February 20, 2018

Is there anyway to tell Pipeline to perform a step ONLY when the pipeline fails?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
mwatson
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2018

No, there is currently no functionality like this.

You could look at this open ticket: https://bitbucket.org/site/master/issues/13317/final-step-required-for-parsing-unit-tests

But it would run a script whenever the step completes, failed or successful. 

You could try using a trap in your script to perform operations if your step has failed, e.g. https://www.shellscript.sh/trap.html

 

Hope this helps!

Mohamed Bana
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 1, 2018

I think you want to trap `EXIT` instead as documented here: http://redsymbol.net/articles/bash-exit-traps/.

 # print logs from the container when a failure happens
- |
function print_logs_on_error {
echo -e "\\033[92m ---> logs reference-mock-server ... \\033[0m";
docker logs reference-mock-server;

echo -e "\\033[92m ---> logs ob-api-proxy ... \\033[0m";
docker logs ob-api-proxy;

echo -e "\\033[92m ---> logs compliance-suite-server ... \\033[0m";
docker logs compliance-suite-server;
}
trap print_logs_on_error EXIT
TAGS
AUG Leaders

Atlassian Community Events