Jenkins sending email on post build

Gustavo Apolinario
May 14, 2018 · 4 min read

After Build you need communicate the persons who can be responsables for the build failure.

You may want send a slack notification too:

Installing Email Extended

Go to Manage Jenkins > Manage Plugins > click on tab Available and search for “Email Extension”.

If you find, install it. If you don’t find it, search in Installed tab because it can be installed.

Configuring Email Extended

To send email, the plugin needs the smtp configured.

Go to Manage Jenkins > Configure System > search for “Extended E-mail Notification”.

Configure the smtp.

Example: My configuration with gmail smtp.

Testing Mail sender

Go to home of jenkins and create a new job. Select pipeline and name it as “SendMail-test”.

Put this pipeline in new job:

This pipeline run in any jenkins agent: (you can has jenkins agents to run code outside your master jenkins server)

It has a stage to sample

In post step, you can run any script you want. We have the mail sender in it.

Save it and run clicking in “Build Now” on job menu.

The build will apear in stage view (if necessary reload the page).

Click on Build Number “#1” and click on “Console Output” on build menu.

The output will be like this:

Go to your email. You must receive a new email like this:

Changing Sender Name

You receive the email, but the sender name is ugly. To change it, go to Manage Jenkins > Configure System.

Search for “System Admin e-mail address” (In Jenkins Location).

Change it to: “Jenkins <jenkins@jenkins>”

Save and run the job again.

The new message has “Jenkins” as sender name.

Sending a post build email with job information

To send a real post build email, create a new pipelinejob and name it as “sample-sender-email”.

Put this pipeline:

This script is a test to you try the post build. You can see more about post build here:

Changing the variable “doError” you can test the failure/success build.

Save and run this job. See your email and you will receive this:

Great! post build configured, you will receive email in all build.

You can change the mail to send only in failure if prefer. (change “always” to “failure”).

You can configure the default value for the plugn. To it, go to Jenkins > Configure System > Extended E-mail Notification

Edit your default value and when you call, use something like that:


You can see more at:

Gustavo Apolinario

Written by

I’m a FullStack Developer, working now with DevOps automations. I previously worked as a front-end, PHP Developer, and DevOps.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade