Jenkins : Email notification on job failure


Introduction

In this article, I will show you how to send email notification in case of job failure.
1.    Install 'Mailer plugin for Jenkins'
2.    Configure Mailer plugin to use
3.    Create Job named TestEmailJob

Step1: Install 'Mailer plugin for Jenkins'

Go to Home->Manage Jenkins->Manage Plugins->Installed tab. Look for the Mailer plugin as shown below. By default, it is installed when Jenkins is installed. If not then it can be installed here.





Step2: Configure 'Mailer plugin' to use

    Go to Home->Manage Jenkins->Configure System->E-mail Notification section.
    Fill up the SMTP server details as shown below. And there is a Test Configuration option in the section to check whether it is working or not.



    Step3: Create Job named TestEmailJob

      Go to Home->New Item and create new job named TestEmailJob as shown in previous examples.
      Now go to TestEmailJob->Configure->Build section.  Here, I have intentionally, 'echo' spelling is written as 'echoa'. So that job gets failed. Just below Build section, I have added Post Build Action. So on job failure, email will be send to responsible users.



      Now, save the configuration and build the job using Build Now menu.
      You can see that job gets failed as expected.  And email should be available to recepient set in the job configuration.




      This is the email I received.


      Comments

      Popular posts from this blog

      Step by step guide for Jenkins FreeStyle Project