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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Sarath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.