Report Build Status in Jenkins

Let’s see how can you report Build Status in Jenkins. In this tutorial, we will, How can we report the error if Build fails in Jenkins.

So suppose we will report the error using Emails if the build fails in Jenkins. In the previous tutorial we have already seen, How can we create the Project in Jenkins and Schedule the project builds in Jenkins and get the build output.

 

There are many ways to report the error but initially, we will take the reported error using email.

To Test this with our ‘TestProject’, first, we need to fail our Project build deliberately.  Nothing to worry just passes some invalid command inside the ‘Command’ in Build options.

 

To report the error using Email. First, you need to configure your project.

  1. Open Jenkins using ‘http://localhost:8080/’
  2. Click your project i.e ‘TestProject’
  3. Click on Configure icon(Present in left menu list)
  4. Scroll down the page and navigate to option ‘Post-build Actions’.(Present in the bottom of page.)
  5. Click on DropList ‘Add Post Build Actions’ and click on the ‘Email Notification’ option.
    Report Error in Jenkins
  6. Enter your desired email and click on Save.

 

You have configured your project successfully. Now Jenkin will send the email to mentioned email address every time when Build gets fail.

But before that, you have to configure the SMTP setting in Jenkins.

 

How to Configure Mail SMTP setting in Jenkins

To configure the SMTP setting in Jenkins. There are fixed steps-

 

  1. Open you Jenkins or go to Jenkins Home if already opened.
  2. Click on the link ‘Manage Jenkins‘ present in the Now clicks on the option ‘Configure System‘.
  3. Scroll down the page and navigate to option ‘E-mail Notification’, click on the ‘Advance’ options. Mail server configuration options will start the display.
    Configure Mail Server in Jenkins
  4. Enter your SMTP or Mail server configuration here. First, enter your SMTP server address. (As I am using google so I will provide the google SMTP mail      server address – smtp.gmail.com)
  5. Check the checkbox ‘Use SMTP Authentication’. Enter the username and password of the account, which you want to use to send the email.
  6. Check the checkbox ‘Use SSL’.
  7. Enter the SMTP port. (For Gmail I will use 465)
  8. Enter the valid email in ‘Reply-to’ field.
  9. Now check the checkbox ‘Test configuration by sending test e-mail’, and enter your valid email in the field ‘Test e-mail recipient’.
  10. Now click on the button ‘Test Configuration’. This will test your settings and sent a test mail to mentioned account.

 

So this all, How we can set up the mail server in Jenkins.

 

Now, We have already configured the mail in the project and we entered the wrong command in Build Command. So when we will run the Build using option ‘Build Now’ the build will be failed and we will get the mail on the mentioned email from Jenkins.

 

0 Comment

Leave a Reply