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
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.
Join now to unlock these features and more
I have multiple steps that should be run on different conditions, and every step should run on the same deployment, so instead of using the inbuild condition which the bitbucket pipeline provided I've started checking within the scripts
Hello @Irfan Nazer and welcome to the Community!
Since pipes are a Bitbucket cloud's feature, their definition must be placed within the step's script YML attributes for it to be correctly identified by pipelines.
One route you could take for putting the conditions in the step while still being able to execute the pipe is to force the exit of the step if the condition is/is not met, as in the following example :
script: - if [[ ! $CONDITION ]]; then exit 0 ; fi #if $CONDITION is not met, exit the step and goes to next step
- npm install
- pipe: atlassian/email-notify:0.11.0 variables: USERNAME: 'firstname.lastname@example.org' PASSWORD: $PASSWORD FROM: 'email@example.com' TO: 'firstname.lastname@example.org' HOST: 'smtp.gmail.com' PORT: 587 SUBJECT: 'Bitbucket Pipe Notification for your-bitbucket-brunch' DEBUG: true
In the above example, if the boolean condition $CONDITION is not met, we will force the completion of the step with exit 0 (so the step will be completed with Success status), which will make the pipelines go to the next step in the build, if any, or complete the pipeline if there are no remaining steps.
On the other hand, if the boolean condition $CONDITION is true, it will continue the execution of the next commands in the step's script, which includes the npm install and the pipe execution.
Hope that helps! Let me know in case you have any questions.
Thank you, @Irfan Nazer !