Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

email notifications

Sarath July 7, 2020

Hi,

can anyone please tell me how to configure the email notifications for every build success/failure. Need to send multiple recipients who is not having the slack subscription.

Few examples already available, but need a step by step implementation to add in the existing repo.

 

Thanks in advance.  

4 answers

1 accepted

1 vote
Answer accepted
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 8, 2020

Hi @Sarath ,

thank you for your question!

It's a good case to use email-notify pipe.


Please, follow next steps to setup it:

Step 1: Configure your Bitbucket repository for the project 

Add your credentials and configuration settings in Bitbucket as variables (see: how to configure Pipelines variables).

Settings > Pipelines > Repository variables:

PASSWORD: The password to authenticate with


Step 2: Setup your CI/CD configuration

Edit and add these steps to bitbucket-pipelines.yml :

image: atlassian/default-image:2

test: &test
step:
name: Test
script:
- echo "Everything is awesome!"

build: &build
step:
name: Build
script:
- echo "Starting build..."
#- <your build logic>
after-script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.3.12
variables:
USERNAME: 'myemail@example.com'
PASSWORD: $PASSWORD
FROM: 'myemail@example.com'
TO: 'example1@example.com, example2@example.com'
HOST: 'smtp.gmail.com'
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'

pipelines:
default:
- <<: *test
- <<: *build
branches:
master:
- <<: *test
- <<: *build


Step3: Check your Pipelines status and messages in your email account )

Ok

 

Note: We recommend using the pipe with your own email server or third-party providers that support massive email notifications (Sendgrid, AWS SES, ...). Some free accounts from vendors such as Gmail or Outlook have special policies about security and rate limiting that could affect configuring and using the pipe. Make sure you read about it and understand their policies before using them.

Sarath July 9, 2020

Hi Oleksandr Kyrdan,

Thanks for reply, I have used gmail smtp server details along with the code you mentioned above. I got the below error.

✖ Failed to send email. Check your configuration settings.

I have enabled the required settings in my gmail security settings. 

Like Joe likes this
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 9, 2020

@Sarath ,

make sure that you've turned on Lesssecure access for your account (periodically Google can turn it off) https://myaccount.google.com/lesssecureapps .

Also, check if no messages in your account about blocked access.

Like Joe likes this
Sarath July 10, 2020

@Oleksandr Kyrdan ,

I have enabled the  Lesssecure access earlier itself. But it is blocking me as you mentioned. So I did use two step verification and created a app password. Its working and I got the email notifications. thanks for the help.

Sarath July 22, 2020

Hi Oleksandr Kyrdan,

 I have achieved the sending email notification from pipeline. But I need to get the commit id of the build and who committed the code, tests case failures if any and a sonar cloud quality checks. Together I need to get evetything about the build failure/success as a report in a single email. Is it possible. if yes please mention the sample  script please.

Like Abryan Manalansang likes this
Abryan Manalansang July 22, 2020

I having same issue as well.

0 votes
Abhishek P February 29, 2024

@Oleksandr Kyrdan Any suggestions / steps for using  AWS SES SMTP for email-notify pipe ?

0 votes
John Ghidiu April 1, 2021

When using Sendgrid, it is important to remember that the username is `apikey` and the password is the API key. The Sendgrid tutorial uses base64 encoded values for username and password, but the Atlassian pipeline specifically uses PLAIN authentication, so it is an error to encode the username and password variables.

0 votes
surajkamble July 28, 2020

Hi @Oleksandr Kyrdan , @Abryan Manalansang , @Sarath 

I have enabled the  Lesssecure access . But still it is blocking me.

if u have steps please send me 

thanks in advance

Sarath July 28, 2020

Hi@surajkamble,

After enabling the  Lesssecure access , on the same security page, you need to turn on 2-step verification and then create a App password which will be provided by google. You have to use this generated app password in your repo. Then you will be able to send the emails.

Like # people like this
surajkamble July 28, 2020

Thank you @Sarath 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events