How to Configure Jenkins Mail Notification on Build Failures

configure jenkins mail, configure jenkins mail notification, how to configure mail notification in jenkins, configure build failure mail notification

When there is a build failure or any changes in the build state, we must get notified immediately through e-mail. so that we can fix the issue at the earliest. There is a mailer plugin available in Jenkins that has be installed and configure it based on the requirement.

In this post, we show you how to configure email notification in Jenkins.

How to Configure Jenkins Mail Notification on Build Failures


Also You can Watch this Tutorial video on our YouTube Channel.
How to Configure Jenkins Mail Notification for Any Build Failures | Jenkins Tutorial

Let's get started.

Once you have logged into Jenkins portal with valid credentials.
jenkins dashboard gui
Step 1: Install Mailer Plugin for Jenkins Mail Notification.
Go to "Manage Jenkins" available at the left side panel.
jenkins portal main screen

Select "Manage Plugins" from the Manage Jenkins Page.

jenkins manage plugins
Go to "Available" tab and Search for "mailer" plugin in filter. Select the plugin "Mailer" and Click "Install without restart".

Selected plugin and its required dependencies also will be installed.

Once the "mailer" plugin is installed. Click "Go back  to the top page", this will take you to the main page of jenkins.

Step 2 : Configure Mail with SMTP authentication
Again go to "Manage Jenkins" and select "Configure System".
Scroll down to find the field "Jenkins Location" and change "System Admin e-mail address" with your Name and E-mail address in the same format as shown in the below image. Because, this is the information about sender and sender mail address.
[ads-post]
Now, Enter your SMTP Server name  in the field "SMTP Server". For this example, I use my personal gmail address to get the mail notification, So I used gmail smtp server. Once this is completed, click "Advanced" button to provide the authentication details.


1. Enable "Use SMTP Authentication"
2. Enter your E-mail ID or username.
3. Enter your password.
4. Mark to "Use SSL".
5. Enter your SMTP Server Port Number.


Once above required information are given, We can check the configuration by sending a test mail.

So, select the option "Test configuration by sending test e-mail" and enter your mail address, click "Test Configuration" button to ensure the mail configuration works properly or not. If everything is ok, you will get an test e-mail from this jenkins server. Finally click "Save".


Step 3 : Configure Jenkins Job Notification

Let's go back to main jenkins job queue and select the job which require notification.

Select "Configure".

Go to "Post Build Actions"


Select "Add post-build action" and Click "E-Mail Notification".


Enter your recipients mail address and select first option "Send e-mail for every unstable build". Click "Save" button.

But, If the second option "Send separate e-mails to individuals who broke the build" is checked, the notification e-mail will be sent to individuals who have committed changes for the broken build (by assuming that those changes broke the build).

If e-mail addresses are also specified in the recipient list, then both the individuals as well as the specified addresses get the notification e-mail. If the recipient list is empty, then only the individuals will receive e-mails.


So we have configured mail notification for build jobs. If there is any failure in build or any changes in build state from failure to success or success to failure, you would get an mail notification.


Sample mail for build failure.


Sample mail for build state changes.


Hope you have got an idea how to configure Jenkins mail notification for any build failure and build state changes. Going forward we will play more with Jenkins integration tool. Keep practicing and have fun. Leave your comments if any.

Also refer other articles,

How to Install & Configure Jenkins Integration tool on Linux
How to Reset Jenkins Admin User's Password | Jenkins Tips
How to Configure Jenkins behind Proxy to Install Plugins
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
Dockerfile Instructions Explained with Examples

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
Incoming searches : configure jenkins mail, configure jenkins mail notification, how to configure mail notification in jenkins, configure build failure mail notification, send mail when build failures, configure email notification, jenkins email configuration, jenkins email notification, email notification in jenkins when build fails, jenkins email notification configuration, configure sending email in jenkins
August 11, 2018

Post a Comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget