Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,563
Community Members
 
Community Events
165
Community Groups

email notification with artifacts

PrasanthK I'm New Here May 18, 2022

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.

1 answer

1 vote
Patrik S Atlassian Team May 19, 2022

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,181 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you