trigger pipeline step on condition

Stève ZEMETA
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!
February 26, 2025

Hi,

I am currently trying to implement a pipeline. But I check,I struggle to find a way to run a step of my pipeline on condition


definitions:
steps:
- step:
name: Run Test
size: 2x # Double the memory allocation
script:
- apk add --no-cache python3 py3-pip python3-dev gcc musl-dev linux-headers curl
- python3 -m venv venv
- source venv/bin/activate
    - step: 
name: Deploy
size: 2x # Double the memory allocation
script:
- echo "test"

- step:
name: Rollback
script:
- echo "Start rollback"



Could you plase help me find the best approach to run Step rollback only in condition that Step Deploy fails

Thank you

2 answers

0 votes
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2025

Hi @Stève ZEMETA

You could possibly use after-script for this? Another option, if you require separated steps, would be to store the result of the deploy in a variable and share with the rollback step.

You might also find BCLOUD-20833 relevant to you.

0 votes
Adrian R_
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!
February 26, 2025

I do not believe bitbucket supports a "Run on failure" condition. You might need to combine the deploy and rollback logic within the same step? For example, you can run a deploy script and then check the scripts exit code.

Suggest an answer

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

Atlassian Community Events