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
Hi there!
I'm wondering if there's any chance to control which are the mandatory steps in a pipeline. By mandatory I mean: I have 2 steps and I always want to run step 2 regardless of the step 1 final status. I know that the after-script config is an option, but I'm looking for something else.
For example, something like this:
image: python:3.10
pipelines:
default:
- step:
name: Step 1
services:
- docker
script:
- echo "This step will run and might fail"
- exit 1
- step:
name: Step 2
services:
- docker
script:
- echo "This step will run regardless of Step 1"
Is there any config like mandatory: false for a given step?
Additionally, I wonder if there's a way to have more than just one pipeline (something like bitbucket-pipelines-2.yml), like in Github where I can create several ones in the .github/workflows directory and each one runs independently, and I can configure which pipeline must block a PR merge for example.
Thanks!
G'day, @Hernán Vignolo
Welcome to the community.
In a serial step process, when a step fails, the build exits with code 1, and the pipeline is considered to have failed. While Bitbucket Cloud doesn't provide a direct way to configure a step as 'mandatory,' it is possible to instruct the pipeline not to exit the process with a non-zero exit code. This allows the pipeline to proceed to the next steps, even if the step has failed.
This method utilizes "set +e" on the commands that you suspect may failed. For example:
image: python:3.10
pipelines:
default:
- step:
name: Step 1
services:
- docker
script:
- set +e echo "This step will run and might fail"
- step:
name: Step 2
services:
- docker
script:
- echo "This step will run regardless of Step 1"
This will force Step 2 to trigger even if the commands in Step 1 failed. We have a KB that explains this more in-depth at:
Pipelines builds succeeds even on command failure
Regarding having two bitbucket-pipelines.yml, this is unfortunately not possible but if you are looking into triggering it separately, you may consider using pipeline start conditions to specifically trigger specific pipeline build independently:
I hope this helps.
Regards,
Syahrul
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.