Header Ads

How to Configure Jenkins Mail Notification on Build Failures

This tutorial post will show you How to Configure Jenkins Mail notification for Build Failures.

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.

If you are interested in learning, Request you to go through the below recommended tutorial.

DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online

How to Configure Jenkins Mail Notification on Build Failures

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.

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 on "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.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
يتم التشغيل بواسطة Blogger.