Set Jenkins to Retry Tests after a Failure

As much as I want to keep user interface tests free of failures, timing issues and page element errors pop up from time to time in automated UI checks. If not a test bug, these often reflect the nature of the app under test, its behavior under certain conditions like the internet connection or the machine slowing down suddenly or the page not loading properly. Such errors can be annoying in tests and if we ever want to continue using them, we’ll have to re-run them some of the time to make sure that errors do exist.

To do this in Jenkins, use the Naginator plugin:

  • Download the Naginator Plugin
  • Install the downloaded plugin to Jenkins (Manage Jenkins -> Manage Plugins -> Advanced -> Upload plugin)
  • Select a desired Jenkins job and then click Configure
  • Scroll down to the Post-build Actions section
  • Add a Retry build after failure post-build action
jenkins_naginator_1

Add test retries as post-build actions

  • Set desired values for the following settings of the retry and then save changes:
    • Rerun build for unstable builds as well as failures (retry can work for unstable builds too)
    • Delay before retrying build (you can set a time delay before running the retry, value in seconds)
    • Maximum number of successive failed builds (means the test will run a certain maximum number of times until it succeeds again after the test fails the first time)
jenkins_naginator_2

Set retry settings: how many times to retry, delay for the next retry, etc

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s