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

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events