Email: info@zenconix.com

Send email by Jenkins

Published on: 12/29/20 3:56 AM

Category:DevOps Jenkins Tags: ,

In this post, we are going to take a look on how to setup basic email configuration for Jenkins and send mail if build job fails.

First and formost, make sure, you have installed some email plugin so that it will allow you to configure email setup.

You can install any email extension plugin example —

Email Extension – https://plugins.jenkins.io/email-ext/

Or

Mailer – https://plugins.jenkins.io/mailer/

I have installed mailer plugin, once it is installed, it will allow us to setup SMTP settings in Jenkins.

Go to “Manage Jenkins” and then go to “Configure System”

Scroll down at below, there we can see setting for Email notification

We are going to use Gmail as SMTP server here in this post.

Enter information as below

SMTP Server: smtp.gmail.com

click on advance button and fill up information as below

Username: your gmail’s username

Password: your gmail password

Use SSL : checked

SMTP Port: 465

Reply-to-adress: your email address

Now check on : Test configuration by sending test e-mail

It will ask to enter recipient’s email address, enter the address and click on “Test Configuration” button.

It should show – Email was successfully sent

Now our email configuration is completed.


Lets create one freestyle project and add some command in Windows Batch Command as build of project for test.

For build, I have just written simple command as ipconfig

Go to post build action

Click on “Add Post build actions” and select “E-mail notification” there

There, add recipient and click on Save button

Here, we are going to send email if build fails.

Lets build our project.

First run has built successfully.

now go to configure project again and make some mistake in our batch command in build section

here I have added invalid command ipconfig1

Now try to build our project again and you can see build has been failed.

and it has send email to your recipient email address.


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Understand build triggers in Jenkins

Hello All, Before getting started to understand build triggers in Jenkins, it is highly recommended to see previous post about Jenkins on our blog so that you will have good idea about Jenkins and will help to understand this post. Lets get started, in previous post, we have seen how to create simple job in […]

Create Parameterized job in Jenkins

In last post, we have seen how to create simple job in Jenkins. Now, in this post we will take a look on how can we create parameterized job in Jenkins. Lets start with creating new project. Click on new item, and create freestyle project as below and hit OK button From general setting, select […]

Create simple jobs in Jenkins

In this post, we are going to see how to create jobs in Jenkins. If you are coming here at first time, I recommend to go to my previous post where we have explained about how to have initial setup for Jenkins in link below. Now, lets get started to create job in Jenkins Give […]