Using Jenkins to Send Email Notifications

06 May 2023 Balmiki Mandal 0 Core Java

How to Send Email Notification From Jenkins?

Jenkins is a popular open source automation software for continuous integration and delivery. It helps developers to build, test, and deploy their applications faster and more reliably. One of the advantages of using Jenkins is the ability to configure email notifications when a build fails or succeeds.

In this article, we will learn how to configure email notifications in Jenkins. We will use a simple application as an example to demonstrate how to configure notifications for success and failure builds.

Prerequisites

  • A Jenkins server
  • A working application that can be built with Jenkins
  • The email address of the recipient of the notification

Step 1: Configure SMTP Settings

Before we can send email notifications, we need to configure the Jenkins server with the relevant SMTP settings. We can do this by navigating to Manage Jenkins > Configure System and then scrolling down to the Extended E-mail Notification section.

Fill out the SMTP server details in the fields provided and hit Save. Once this is done, we can move on to configuring the notification settings.

Step 2: Configure Jenkins Email Notification Settings

The next step is to configure the email notifications in Jenkins. Navigate to Manage Jenkins > Configure System and scroll down to the E-mail Notification section.

Here, you need to provide the recipient's email address and specify the content of the notification. This can include text, HTML, and attachments, depending on your requirements. You can also choose to attach the build log, if needed.

Once all the details are filled out, hit Save.

Step 3: Configure Notification Settings for Each Build

Finally, we need to configure the notification settings for each build. Navigate to the job you want to configure and click on the Configure link. Scroll down to the Post-build Actions section and click on the Add post-build action button.

From the dropdown menu, select Editable Email Notification. Select whether you want to send an email for success or failure builds, or both. Provide the recipient's email address and any other details you want to include in the notification. Once done, hit the Save button.

Conclusion

In this article, we learned how to configure email notifications in Jenkins. We started off by configuring the SMTP server details which will be used to send the emails. Then, we configured the global email notification settings. Finally, we configured the notification settings for each build.

With these simple steps, Jenkins can now send email notifications when a build starts, succeeds, or fails.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.