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

how to make execution of "email notify pipe" optional based on condition

Deleted user January 17, 2024

Hi ,

I have a bitbucketpipelines and i have defined the email notify pipe inside it.

i want to send email based on some if condition but rest of the code must execute . i have written the if condition but its exit when meet the condition and not executing scripts defines after that .. ie. i want to execute  ./deployment.sh always

e.g. 

 

branches:
testing:
- step:
name: Test 
script:
- my_condition="$env_var"
- subject="subject"
- desc="desc"
- if [ ! "$my_condition" ]; then exit 0 ; fi
- pipe: atlassian/email-notify:0.12.0
variables:
USERNAME: $UNAME
PASSWORD: $PWD
FROM: $FROM
TO: $TO
HOST: $HOST
PORT: $PORT
TLS: $TLS
SUBJECT: "$ubject"
DEBUG: $TRUE
BODY_PLAIN: "$desc"
# Build Part
- export ENV=$BRANCH
- python -m pip install -r requirements.txt
- ./deployment.sh $ENV

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 22, 2024

Hi Deepak and welcome to the community!

The only way to achieve what you want at the moment is by placing the if command and the pipe command at the end of your script in your yml. So, first execute all the other commands, including ./deployment.sh, and then add the if statement and the pipe.

This is the only way because it is not possible to include the pipe in the body of an if statement.

We have a feature request for this that you can vote for here: https://jira.atlassian.com/browse/BCLOUD-20555

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
TAGS
AUG Leaders

Atlassian Community Events