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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Mandatory steps and/or mutiple pipelines

Edited
Hernán Vignolo
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!
Oct 20, 2023

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!

1 answer

1 accepted

0 votes
Answer accepted
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 22, 2023

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:

Pipeline start condition 

I hope this helps.

Regards,
Syahrul

Hernán Vignolo
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!
Oct 23, 2023

Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events