In this post, we will look into the jenkins configuration to send email notifications & sending attachments to the email notification triggered.
For this we will see how we can send an email notification to any gmail account from jenkins.
- Jenkins installation
- Have a Jenkins job with selenium or any other project to run tests
- Install plugin Mailer if not yet installed
- Install another plugin Email Extension [we will be discussing at end of this post]
Watch the below discussion in action here –
For Mailer plugin
Navigate to Manage Jenkins > Configure System
Scroll down to “E-mail notification” section & enter the gmail SMTP server details to get email triggered to any gmail account
SMTP server :
Default user e-mail suffix :
Click on the
Advanced... button and enter all other details as below
User Name :
Password : [your gmail account password from where email will be triggered]
Use SSL :
SMTP port :
After all the details were entered, now check the box “Test configuration by sending test e-mail”, and enter any email address to receive an email and verify.
Save the page.
Turn ON the less secure app access for gmail account
Load the url & login to –
Allow less secure apps: ON
Under Jenkins dashboard > Project
Navigate & open the Jenkins job where selenium project is present and want to run the test
Under Build settings section –
check the email check box & enter the email address[s] to receive an email
Save the job configuration and save the changes.
build to run the tests.
As soon as the build is done, you will receive an email to your recipient email inbox.
Email Extension plugin
With the Mailer plugin [as discussed above], we don’t have much customisation like subject & body content customisation or attaching files etc.
So there is another plugin Email Extension plugin you can install in Jenkins.
Configuration is pretty much similar to above with some extra fields to add or edit values.
For this plugin configuration, navigate to
Manage Jenkins > Configure System > scroll to "Extended E-mail Notification" section
SMTP server configuration is same as the Mailer plugin [as discussed above], along with this you will get some more options as shown below to customise the subject & body of the email
You can use Build related global variables to display the values in email
Default Subject & Default Content – customise as you want to display the email subject & body you will receive.
Maximum attachment size – default to -1, to not limit the size of attachment
Save the changes
Under Jenkins dashboard > Project
Navigate to Configure > Post build actions > select the “Editable email notification”
You can leave the field as the default entry or can customise as you need
You can add multiple recipient list using comma separated along with the
default recipient list [entered under Manage jenkins > Configure System]
The same way you can customise the
default subject & content specific to your project or leave as it is.
To attach files in email notification >
Under the Attachments field, you can add one or multiple file path to attach [As shown below image]
Note – the base directory should be the Jenkins workspace, you can’t specify your local drive path [you can symlink the local drive path to jenkins workspace if you run tests from local drive]
Optional – you can select the build log to attach or not from the “Attach Build Log” field.
You can specify when you want to receive the email notification, on failure or success etc under the
When you add the Tigger as always, then you will receive the email notification irrespective of success or fail test run.
Console output example –
[htmlpublisher] Archiving at PROJECT level /Users/skpatro/.jenkins/workspace/[jobName]/ExtentTestReport to /Users/[MyUser]/.jenkins/jobs/[JobName]/htmlreports/HTML_5fReport [Checks API] No suitable checks publisher found. Email was triggered for: Always Sending email for trigger: Always Sending email to: email@example.com firstname.lastname@example.org Finished: UNSTABLE
This will ensure that email has been triggered.
Hope this helps!