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
How do I add the logic to a pipe to check the build exit code and only send email upon failure?
I'm using the same script, but even the status is success the email is sent BUt I want onlt the email be sent when the step before is failed.
Otherwise how can I use my company email (generated from Mircosoft 365) to sen the email?
Hello @yosser_mahfoudh and welcome to the Community!
You can use the pipeline default environment variable BITBUCKET_EXIT_CODE :
The exit code of a step, can be used in after-script sections. Values can be 0 (success) or 1 (failed)
to create an if condition and check if the step is successful or not.
Following is an example of using that variable, along with the atlassian/email-notify, to send email notifications with the build status :
pipelines:
default:
- step:
name: Build and Test
script:
- echo "abc"
after-script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.10.0
variables:
USERNAME: 'myemail@example.com'
PASSWORD: $PASSWORD
FROM: 'myemail@example.com'
TO: 'example1@example.com'
HOST: 'smtp.gmail.com'
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'
For further instructions on how to configure the variables required to execute that pipe, you can refer to its official documentation below :
Hope that helps! Let me know in case you have any questions.
Thank you, @yosser_mahfoudh !
Patrik S
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.