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:
STEP 1 # Create 2FA Google Account
Navigate to your Google account settings:
Google account ➔ Security ➔ 2 Step Verification ➔ Apps Passwords ➔ Create app passwords
STEP 2 # Create Credentials Jenkins
Create credentials for email in Jenkins and copy-paste the token obtained from the 2FA process in Gmail.
Configure email in the global Jenkins settings:
Select "Manage Jenkins" ➔ "System" ➔ "Extended Email Notification"
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"
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!
STEP 3 # Create Job Pipelines Jenkins
Create job pipelines to test sending email notifications:
Select build environment ➔ Editable Email Notification
Select 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.
Alhamdulillah, the Jenkins pipeline job has been successful.
You have successfully sent Jenkins notifications to the target email.
No comments:
Post a Comment