How to send a Pipeline Build status email from Bitbucket Cloud Pipelines

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

This article highlights the process behind sending an email to a specific user with the pipeline build status of a build executed from Bitbucket Cloud Pipelines.

Solution

The Email notify pipe can be used to send an email from Bitbucket Pipelines by configuring it within your YML file:

Example: Sending an email using Google (Gmail):

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 image: atlassian/default-image:latest pipelines: default: - step: name: test email pipe script: - exit 1 after-script: - STATUS="success" - if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then STATUS="FAILED" ; fi - pipe: atlassian/email-notify:0.13.1 variables: USERNAME: $USERNAME PASSWORD: $APP_PASSWORD FROM: 'SENDER'S_EMAIL_ID' TO: 'RECIPIENT_EMAIL_ID' HOST: 'smtp.gmail.com' PORT: 587 SUBJECT: 'BUILD# ${BITBUCKET_BUILD_NUMBER} ${STATUS}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}.'

Alternatively, if you'd like to send an email notification only when the build has failed, you can use the below YAML configuration:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 image: atlassian/default-image:latest pipelines: default: - step: name: test email pipe script: - exit 1 after-script: - if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then echo "Step failed" ; else exit 0; fi - pipe: atlassian/email-notify:0.13.1 variables: USERNAME: $USERNAME PASSWORD: $APP_PASSWORD FROM: 'SENDER'S_EMAIL_ID' TO: 'RECIPIENT_EMAIL_ID' HOST: 'smtp.gmail.com' PORT: 587 SUBJECT: 'BUILD# ${BITBUCKET_BUILD_NUMBER} ${STATUS}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}.'

ℹ️ Replace USERNAME with the EMAIL_ID, and PASSWORD with the APP_PASSWORD created from the Google account. Also, replace the Sender's and Recipient's Email ID.

ℹ️ Please note that due to changes in Google not supporting less secure apps (see Google changes for less secure apps), to make this pipe work with a Google account, you have to create a Google app password.

If you are unable to configure build status emails after following this article, please raise a support ticket or a community support ticket for further assistance.

Description

How to send a Pipeline Build status email from Bitbucket Cloud Pipelines

Product

Bitbucket Cloud

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.