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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

email notifications

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.  

2 answers

1 accepted

0 votes
Answer accepted

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.

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. 

@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.

@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.

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

I having same issue as well.

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

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 Simon Arame likes this

Suggest an answer

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

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,323 views 0 3
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