Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

pipeline catch fail-fast

qq
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 25, 2024

 

Hello everyone,

 

As part of the recent rework on our Bitbucket pipeline, I moved several deployment steps to run in parallel to reduce execution time. I also grouped these steps and applied the fail-fast: true option, so if one deployment fails, all other deployments to different servers are stopped, which is working as intended.

 

However, in the event of a failure, we need to perform cleanup tasks on the hosts, such as removing certain files or running checks to ensure everything is functioning correctly.

 

I’m now wondering if there’s a way to conditionally trigger a cleanup step specifically when fail-fast is activated.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2024

Hi and welcome to the community!

A conditional step with a static bitbucket-pipelines.yml file is not possible.

It may be possible with dynamic pipelines but I am not 100% sure. You can post question in this group:

and ask if dynamic pipelines can address your specific use case. Please keep in mind that dynamic pipelines are available for workspaces on the Premium billing plan.

 

Another option is to use an after-script for each parallel step. In the after-script, you can check the step's exit code and if it is 0, you can exit the after script:

if [ "$BITBUCKET_EXIT_CODE" == "0" ]; then exit 0 ; fi;

Otherwise, the rest of the after-script's commands will be executed.

Please keep in mind that if you have three parallel steps and e.g. the first one fails, then the other two steps will be stopped. Only the first's step's after-script will get executed, as after-scripts don't run for stopped steps. So, you would need to include clean-up commands for all hosts in the after-script, and then use the same after-script in all parallel steps.

Please feel free to reach out if you have any questions!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events