How to configure Email notification in Jenkins.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

This post is about configuring Email Notification in Jenkins.

Introduction

Emails have played a significant role in each association because of their convenience, and accessibility. A few plugins are accessible in the market that work wonders in order to configuring each part of email notifications. In Jenkins, we will see one of them. Jenkins email notification is based on Java plugin tool and it plays an important role in continuous Integration as it is used to send the notification alert automatically when an email is received.

Email Notification in Jenkins
Email Notification in Jenkins

Why do we need it?

Assume the release of the application is planned at 12 PM. and on the test or production servers, there is an issue with the application or it goes down within a few hours after its release, then this can bring about the deficiency of millions of dollars. 

Email Notification in Jenkins

The solution to this problem is Jenkins which is an automation tool. To handle this type of issue, a service of Email Notification has been introduced in Jenkins.

Developers are notified when there is any failure in the build by the Email plugin. Also, we can set up the email of the concerned person to whom we want to send the notifications. As soon as the developer or concerned person gets the email notification, they can fix the error and rebuild the code. By using this plugin we can save our time and also prevent bad impressions from clients.

Step 1: In this step, you need to install the Email plugin, in order to do so, follow these steps:

  • Navigate to Manage Jenkins, then Manage Plugins.
  • Navigate to the Available tab then type email in the search box.
  • Select the Email Extension Template Plugin.
  • Click on Install without restart.

Click on “Restart Jenkins when installation is complete and no jobs are running”.

Step 2: In this step, you need to Configure the SMTP server, in order to do so, follow these steps.

Go to Manage Jenkins >> Configure system. You will be redirected to the configuration page where you have to enter the details of the E-mail notification, Enter the required fields:

  • SMTP server; Type the SMTP server name according to your email domain. I am using the SMTP server of Gmail.
  • Click on advanced for more options.
Email Notification in Jenkins
Email Notification in Jenkins
  • Click on Use SMTP Authentication checkbox.
  • User Name; Type the email address which is used for sending/receiving the email.
  • Password; Type the password same as your email password.
  • Use SSL; click on the checkbox for connecting to the SMTP server.
  • SMTP Port;  For SSL it’s 465 and for TLS, the port number is 587, so choose as per your mail server.
  • Click on the box of “Test configuration by sending test e-mail”.
  • Enter the email in the Test e-mail receipt box. 
  • Just to confirm the email id is valid, click on Test configuration then Apply and Save.

Step 3: In this step, you need to create the Jenkins job to test the Email notification. Also, you can apply this email notification to the existing Job.

  • Create the new Jenkins job if you don’t have an existing one.
  • On the configuration page of the Jenkins job, click on the Post-build Actions from the top menu.
  • Click on Add post-build action.
  • Click on E-mail notification from the dropdown menu.

  • An E-mail notification box opens with different options.
  • Type the Recipients email id on which you want to get the notification, it could be one or multiple emails.
  • Click on Apply and Save.

So after the execution of the job, whenever the build fails, you will get notified by mail. 

In this way, you can set up Jenkins Email notifications. This is it from my side in this article.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Jaswinder Singh
Jaswinder Singh
DevOps Engineer

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook