hi,
Can anyone please tell me how to configure the email notifications for every build "Success/Failure", If build is "Success" need the "Artifacts" to be attached with email as well.
few examples are there, a step by step implementation will be more helpful.
Thanks.
Hello @PrasanthK ,
Welcome to Atlassian Community!
You could configure an after-script section in your step combined with the pipe atlassian/email-notify to send an e-mail with the status of the build and also with the artifacts attached.
The after-script section is always executed independently if the commands in the step have failed or not.
Please allow me to share a configuration example using Gmail's SMTP:
pipelines:
default:
- step:
script:
- echo "This is test command 1" > file1.txt
- echo "This is test command 2" > file2.txt
after-script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.7.0
variables:
USERNAME: 'example@example.com'
PASSWORD: $PASSWORD
FROM: 'example@example.com'
TO: 'example@example.com'
HOST: 'smtp.gmail.com'
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'
ATTACHMENTS: 'file1.txt,file2.txt'
DEBUG: 'true' #OPTIONAL
The example above creates two text files (file1.txt and file2.txt) in the default directory as part of the step's script. The after-script section will check the value of $BITBUCKET_EXIT_CODE to define if the commands executed in the step were successful or not ( 0 exit code equals success). Then it will send an e-mail with the status of the build - 'success' or 'error' - and the created files attached, accordingly to the values configured in the variable section of atlassian/email-notify pipe.
You can adapt the above example with your current e-mail provider. For detailed instructions on how to configure the pipe, you can refer to its official documentation :
This documentation also provides links to the most common providers and how you should configure them.
Hope that helps! In case you have any further questions related to this topic, please let me know.
Thank you, @PrasanthK .
Kind regards,
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.