Skip to content
Latchkey

How to Retry a Failing Task in Azure Pipelines

Azure Pipelines re-runs a failing step automatically with retryCountOnTaskFailure.

Add retryCountOnTaskFailure to a task: or script: step. Azure re-runs that step up to that many times on failure.

Retry a flaky step

This step is retried up to twice on failure before the job is marked failed.

azure-pipelines.yml
steps:
  - script: npm run test:integration
    displayName: Integration tests
    retryCountOnTaskFailure: 2

Gotchas

  • retryCountOnTaskFailure retries only that step; it does not re-run the whole job.
  • It retries on any failure - do not put it on test steps where a real failure should stop the run.
  • There is no built-in backoff; for delay-and-retry on a single command, script a bash loop instead.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →