Certified Jenkins Engineer
Automation and Security
Demo Email Extention Notification Freestyle
In this tutorial, we’ll replace Jenkins’s built-in email notifications with the powerful Email Extension Plugin. You’ll learn how to install the plugin, configure global SMTP settings, and customize notifications for your Freestyle jobs—including attachments and conditional triggers.
1. Install the Email Extension Plugin
- Go to Manage Jenkins → Plugin Manager → Available.
- Search for Email Extension Plugin and click Install without restart.
- When installation completes, restart Jenkins.
Note
Refer to the official Email Extension plugin documentation for advanced examples and template syntax.
Once Jenkins restarts, log in and confirm the plugin appears under Installed.
2. Configure Global Email Settings
Navigate to Manage Jenkins → Configure System and scroll to Extended E-mail Notification. Set up your SMTP details:
Setting | Value | Description |
---|---|---|
SMTP Server | smtp.gmail.com | Gmail SMTP host |
SMTP Port | 465 | SSL port |
Use SSL | ☑️ | Secure connection |
Credentials | Add Gmail Username/Password | Use an app-specific password |
Default Content Type | text/html | HTML format for email body |
Attachment Size Limit | (leave blank) | Unlimited by default |
- Add Credentials
Click Add → Jenkins and select Username with password.- Username: your Gmail address
- Password: an app-specific password
Note
Generate an app-specific password in your Google Account under Security → App passwords.
- Select the new credentials and enable Use SSL.
- Default List-ID Header
Optionally specify a List-ID to group your emails.
- Default Subject & Body
Use tokens like${PROJECT_NAME}
,${BUILD_NUMBER}
, and${BUILD_STATUS}
.
- Default Triggers
Enable Failure – Any, and add others (e.g., Unstable, Always) as needed.
Trigger | Sends When |
---|---|
Failure – Any | Any build failure |
Unstable | Builds with test failures |
Always | Every build, regardless of outcome |
Click Apply and Save to persist.
3. Configure a Freestyle Job
Open your Freestyle project (e.g., npm-version-test) and click Configure.
Remove any existing E-mail Notification.
Under Post-build Actions, select Add post-build action → Editable Email Notification.
Add a Shell Build Step to simulate failure:
echo "Updating job config using Jenkins CLI" node -v npm -v exit 1
Warning
The
exit 1
command will force the build to fail to trigger the failure notification.Project Recipient List
Leave blank to use global defaults or specify an address (e.g.,[email protected]
).
- Leave Default Subject and Default Content inherited from global settings.
- Click Apply and Save.
3.1 Trigger a Build Without Recipients
Run the job to see:
Email was triggered for trigger: Failure - Any
Sending email for trigger: Failure - Any
An attempt to send an e-mail to empty list of recipients, ignored.
By default, the plugin only mails Developers, not your recipient list.
4. Add Recipients and Rerun
- In Editable Email Notification, expand Advanced Settings.
- Under Default Recipients, add your email or check Send to Recipient List for each trigger.
Save and rebuild:
Now the console shows:
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
Sending email to: [email protected]
5. Verify in Your Inbox
You should receive a notification with your default HTML template:
6. Attach the Build Log
To include the build log in your notification:
- Under Editable Email Notification → Advanced Settings, enable Attach Build Log and optionally Compress Build Log.
- Save and rerun the job.
The next email will include build.log
as an attachment:
You’ve now set up the Jenkins Email Extension Plugin for Freestyle jobs—covering installation, global SMTP configuration, project-level notifications, triggers, and attachments.
Watch Video
Watch video content