How to queue builds with automatic retry on failure
Description
The technique described here will help you if you have builds that have intermittent problems that often are successful on a retry of all failed jobs. In our environment, we run builds with large number of jobs running Gint test scripts with hundreds or, in some cases, thousands of tests. Occasionally, environmental issues like underlying application failures or other system issues may prevent tests from being totally successful (false negatives for the code being tested). Retrying these failed jobs often succeeds. Automatically queuing the retry means fewer false negatives that need to be investigating. Â
Example
Using CLI 9.0 or higher:
- By using the exact build key in the second queueBuild, it will rerun only failed jobs in the the existing build. This helps significantly for builds that may have intermittent problems.
-a run --input "-a queueBuild --plan EXAMPLE-RETRY --wait" --input "-a queueBuild --plan @build@ --wait" --continue
Even better when using CLI 9.3 or higher:
- You can easily condition the running of the second build to avoid an error being generated for a successful build (since you cannot retry a successful build):
-a run --input "-a queueBuild --plan EXAMPLE-RETRY --wait" --input "-a runIf --regex FAILED --value @buildState@ --input \"-a queueBuild --plan @build@ --wait\" " --continue
The above examples are using linux command line quote escaping (\"). On Windows, use windows escaping ("").