Is there anyway to tell Pipeline to perform a step ONLY when the pipeline fails?
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!
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
It looks like you're new here. Sign in or register to get started.