You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi Folks,
Need your help in one thing. I have a BB pipeline which consist of 4 steps . If Any of 3 steps failed there should be option for me to run 4th step directly.
Scenario : If any of step gets failed the 4th step should run with a manual trigger.
How Can I Achieve that. Any help is highly appreciated .
Hello @Shrey ,
Thank you for reaching out to Atlassian Community!
I'm afraid that currently, Bitbucket cloud pipelines will not continue to the next steps when a step failed. Whenever a step fails, the pipeline execution will be stopped and none of the next steps will be executed. We do have a feature request to implement an option to allow a step to fail and continue to the following steps :
We encourage you to add your vote there, so it gives that feature traction, and also add yourself as a watcher to be notified of any update on that feature implementation.
While that option is not available, you might be interested in using the after-script option in your step. The after-script section will always be executed at the end of a step, regardless if the step succeeded or failed. You could add some logic to the after-script section for it to run only when the step fails, like in the below example :
pipelines:
default:
- step:
name: Step 1
script:
- echo "test step"
after-script:
- if [[ BITBUCKET_EXIT_CODE -eq 0 ]]; then exit 0; else echo "Step failed"
- echo "only execute this if step failed"
In this example, in the after-script section, we are evaluating the value of the variable BITBUCKET_EXIT_CODE
that will contain the exit code of the last command executed in the step. If this exit code is zero (meaning the step's script commands were executed successfully) the after-script section will be forced exit. On the other hand, if BITBUCKET_EXIT_CODE
is different than zero (meaning one of the step commands has failed) the after-script section will be executed up to its end, so you can include any commands there that you would like to be executed only on step-failure.
For more details about the after-script section you can check our official documentation below :
Thank you, @Shrey !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.