Breaking

How to configuration notification email in jenkins

Devopsgol - Jenkins is a highly relied upon CI/CD tool by DevOps due to its capability to automatically and continuously integrate tools and development. In the previous article, we discussed Jenkins notifications via Slack. Today, we will cover Jenkins notifications via email.

To enable email notifications for gmail.com, you need to activate the 2FA (Two-Factor Authentication) feature and create an app password to obtain the 2FA token from gmail.com. Here are the steps:

How to configuration notification email in jenkins


STEP 1 # Create 2FA Google Account 


Navigate to your Google account settings:
Google account ➔ Security ➔ 2 Step Verification ➔ Apps Passwords ➔ Create app passwords

How to configuration notification email in jenkins

STEP 2 #  Create Credentials Jenkins

Create credentials for email in Jenkins and copy-paste the token obtained from the 2FA process in Gmail.

How to configuration notification email in jenkins

Configure email in the global Jenkins settings:

Select "Manage Jenkins" ➔ "System" ➔ "Extended Email Notification"

How to configuration notification email in jenkins


How to configuration notification email in jenkins

Note:

SMTP server: smtp.gmail.com
SMTP port: 465
Use SSL: Check
Default Recipients: Fill in the list of emails that will receive notifications from Jenkins pipelines.

Configure email notification in Jenkins:

Select "Manage Jenkins" ➔ "System" ➔ "Email Notification"

Configure email notification


Note:

SMTP server: smtp.gmail.com
Default user email suffix: @gmail.com (domain from the mail server)
Use SMTP Authentication: Check the checkbox
Username: Enter the email address as the notification sender
Password: Paste the token generated from 2FA in Gmail
Perform a test sending of the email notification

Congratulations, the email sending test has been successful!

sending  email testing notification jenkins

STEP 3 #  Create Job Pipelines Jenkins 

Create job pipelines to test sending email notifications:
Create  job pipelines in jenkins


Select build environment ➔ Editable Email Notification
post-build environtmen


Select post-build-actions

post-build-actions


Note:

Project Recipient list: Enter your email
Project Reply to list: Enter your email
Content type: HTML
Default subject : Default content:

Click "Build Now" to execute the pipeline job.

build now


Alhamdulillah, the Jenkins pipeline job has been successful.

Alhamdulillah, the Jenkins pipeline job has been successful.



You have successfully sent Jenkins notifications to the target email.

successfully sent Jenkins notifications to the target email.


No comments:

Post a Comment