How to Retry a Failed Build in Jenkins?

Retry builds after failure in Jenkins

  1. Open Jenkins using the URL: http://localhost:8080/ on any browser.

Open Jenkins using the URL httplocalhost8080 on any browser.

2. Click the ‘Manage Jenkins’ menu displayed on the right side of the screen. You will be redirected to the ‘Manage Jenkins’ page, where you need to select the ‘Manage Plugins’ option.

You will be redirected to the ‘Manage Jenkins’ page, where you need to select the ‘Manage Plugins’ option.3. Click on ‘Available’ once you are at ‘Manage Plugins’ page.

Click on ‘Available’ once you are at ‘Manage Plugins’ page.

4. Enter ‘Naginator’ in the ‘Filter’ field displayed at the right side of ‘Manage Plugins’ page.  It will display the ‘Naginator Plugin’ option. Select the option and click the ‘Install without restart’ button.

Naginator Plugin

Install without restart

5. Now go to the home page and click on the created job. Click the ‘Configure’ button.

click on the created job. Click the ‘Configure’ button.

6. You will be redirected to the ’Testing’ job project, where you need to click the ‘Configure’ link displayed at the left side of the page.

click the ‘Configure’ link

7. Choose the ‘Add post build action’ option from the dropdown as shown below.

Choose the ‘Add post build action’

8. Now select the ‘Retry Build after failure’ field.

select the ‘Retry Build after failure’ field.

9. You will see the ’Retry build after failure’ configuration section being displayed.

Retry build after failure

10. There are 3 configuration settings (as numbered in the above image). Let’s discuss each in detail.

This option indicates whether you should retry the UNSTABLE state builds in addition to FAILURE state builds. So, let’s set it to true.

This allows you to define how long to delay retrying build start-time from the time it was failed. There are two options to choose from; one is to provide a “fixed period” and the other is to provide an “increasing period”. So, let’s use fixed period; and set it to 180 (3 minutes).

This is used to control the number of continuous failure builds. Jenkins will not automatically retry more than this maximum number of consecutive failures. So, let’s set 2, so that it is retried only two times.

11. Now, run the build and see it executing two times after the failure.

run the build and see it executing two times after the failure.

SHARE THIS

Get A Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.