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

Can we add a pipeline step that will execute even on previous steps failed (not after script)

Chandramouli Naraharisetti May 4, 2022

I've configured runner in EC2 and I've below steps for test automation executions

Step1 - Start machine (runs on - Bitbucket image)

Step2- Run automation scripts (run on - self hosted runner)

Step3- Stop machine(run on - Bitbucket image)

If step2 failed due to some failed tests , Step2 will be skipped. But i want to close the EC2 instance in step3 . 

 

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2022

Hi @Chandramouli Naraharisetti

Thank you for reaching out to the community.

Unfortunately, while using the Bitbucket Pipelines multi-steps, if you have 3 steps and the 1st or 2nd step is failed, it won't proceed to the 2nd or 3rd step.

For this, the best I can suggest is to catch the scenario you've described using after-script.

For example, in your 2nd step, you can set up after-script that when step 2 is failed, go ahead and close the EC2 instance.

  • Step 1:
  • Step 2:
    • after-script
      • If: Failed
        • Do close EC2 instance
      • Else: Success
        • Do something else/nothing
  • Step 3: Do close EC2 instance

Essentially, your after-script scripts for the 2nd and 3rd steps are slightly the same. (This is because, in the 2nd step's after-script, you'll need to do an if/else)

Hope it helps and let me know if you have further questions.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events