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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Run A Step if Above Steps Failed

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 .

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 13, 2023

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 : 

    - step:
        name: Step 1
          - echo "test step"
          - 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

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events