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.
- Open Jenkins using ‘http://localhost:8080/’
- Click your project i.e ‘TestProject’
- Click on Configure icon(Present in left menu list)
- Scroll down the page and navigate to option ‘Post-build Actions’.(Present in the bottom of page.)
- Click on DropList ‘Add Post Build Actions’ and click on the ‘Email Notification’ option.
- 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-
- Open you Jenkins or go to Jenkins Home if already opened.
- Click on the link ‘Manage Jenkins‘ present in the Now clicks on the option ‘Configure System‘.
- Scroll down the page and navigate to option ‘E-mail Notification’, click on the ‘Advance’ options. Mail server configuration options will start the display.
- 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)
- Check the checkbox ‘Use SMTP Authentication’. Enter the username and password of the account, which you want to use to send the email.
- Check the checkbox ‘Use SSL’.
- Enter the SMTP port. (For Gmail I will use 465)
- Enter the valid email in ‘Reply-to’ field.
- Now check the checkbox ‘Test configuration by sending test e-mail’, and enter your valid email in the field ‘Test e-mail recipient’.
- 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.
Products from Amazon.in
Price: Check on Amazon
Price: INR 29,999.00
Price: INR 15,390.00