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

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Cloud のみ - この記事は、 クラウド プラットフォームのアトラシアン製品にのみ適用されます。

要約

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. 

ソリューション

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):

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:

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}.'

(info) 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. 

(info) 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.

説明 How to send a Pipeline Build status email from Bitbucket Cloud Pipelines
製品Bitbucket Cloud



Last modified on Mar 26, 2024

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.