Auto-Retry
Automatically retry failed CI jobs to reduce false negatives caused by flaky tests and transient failures.
CI Insights Auto-Retry re-runs a failed CI job when the failure matches a rule you wrote, so a flaky test or a transient error does not leave the run red.
How auto-retry works
Section titled How auto-retry worksWhen a job fails, Auto-Retry evaluates it against the retry rules of its repository. If one matches, Mergify retries the workflow run once it has finished.
Configuration
Section titled ConfigurationAuto-Retry uses a rule-based system to determine which workflow runs should be retried. Rules are evaluated against individual jobs, but retries occur at the workflow level. Each rule belongs to a single repository, chosen from the repository selector at the top of the Auto-Retry page.
Basic setup
Section titled Basic setupTo set up Auto-Retry for a repository:
- Navigate to your Mergify dashboard
- Go to CI Insights → Auto-retry
- Pick a repository from the selector at the top of the page
- Configure your retry rules for that repository
You can view, create, edit, or delete rules scoped to the selected repository. Switch repositories from the selector to manage another one.
Retry rules
Section titled Retry rulesAuto-Retry rules define when a workflow should be retried based on job failures. Each rule specifies:
-
Name: Required, and unique within the repository. Mergify refuses a rule saved under a name another rule already uses
-
Conditions: When the job failure should trigger a workflow retry
-
Number of retries: How many times a matching job may be retried, from 1 to 10
-
Retry mode: Whether to retry all failed jobs (Failed job only, the default) or the entire workflow (Entire workflow). These are the
jobandpipelinemodes described under How auto-retry works
When several rules match the same failed job, the one allowing the most retries
applies. Because Mergify issues a single retry per workflow run, a run whose
failed jobs match rules with different retry modes is retried in pipeline
mode, the broader of the two. Jobs that ran on a merge queue’s
batch pull request are not retried, because the queue
closes or replaces that pull request once it has read its checks, leaving a
re-run nowhere to report.
Conditions
Section titled ConditionsConditions let you control which job failures should trigger a retry. Each condition matches against a specific attribute of the failed job. Every rule needs at least one condition, and when you combine several in a single rule, all of them must match for the rule to apply.
The following condition attributes are available:
-
Job name: Match against the name of the failed job. This allows you to target retries to specific jobs known to be flaky.
-
Pipeline name: Match against the name of the workflow (pipeline) that contains the failed job.
-
Branch: Restrict the rule to specific branches. You can also enter custom branch names that are not yet in the list. Branch matching is case-sensitive, unlike job name, pipeline name, and conclusion, which ignore case.
-
Conclusion: Match against the type of failure. Available values are
failure(the job failed) andtimed_out(the job exceeded its time limit). -
Flaky: Match against whether Mergify has detected the job as flaky. Set to
trueto only retry jobs that have been identified as flaky, orfalseto only retry jobs that are not considered flaky. -
Log pattern: Match against the content of the job logs and GitHub Actions check-run annotations using regular expressions. Each pattern is evaluated against individual log lines. You can specify multiple patterns; a retry is triggered if any of the patterns match. For example,
timeout|connection refusedwould match any log line containing either “timeout” or “connection refused”. The rule builder includes a Test your log patterns panel to check your log-pattern regex against sample log text before saving.
Was this page helpful?
Thanks for your feedback!