---
title: Automatic Job Retries
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Continuous Integration Visibility > CI Pipeline Visibility in Datadog >
  Automatic Job Retries
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Automatic Job Retries

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Automatic job retries save developer time by re-running failures that are likely transient, such as network timeouts, infrastructure failures, or flaky tests. Genuine code defects are not retried. Datadog runs each failed job through an AI-powered error classifier. When the failure is identified as retriable, Datadog triggers a retry through the CI provider's API without manual intervention.

Automatic retries reduce the number of pipelines that developers re-run by hand, shorten feedback loops, and keep pipeline success metrics focused on non-transient failures.

{% alert level="info" %}
Automatic job retries are available for [GitHub Actions](https://docs.datadoghq.com/continuous_integration/pipelines/github.md), [GitLab](https://docs.datadoghq.com/continuous_integration/pipelines/gitlab.md), and [Azure Pipelines](https://docs.datadoghq.com/continuous_integration/pipelines/azure.md).
{% /alert %}

## How automatic job retries work{% #how-automatic-job-retries-work %}

When a job in your CI pipeline fails:

1. Datadog's AI error classifier inspects the job's logs and error context to determine whether the failure is transient.
   - This is the same AI error classifier used by [Logs Analysis](https://docs.datadoghq.com/continuous_integration/guides/use_ci_jobs_failure_analysis.md), which reads relevant job logs to decide whether a failure is transient.
1. If the failure is classified as retriable, Datadog requests a retry through the provider's API.
1. Datadog retries each failing job up to a maximum number of attempts (set by Datadog) to prevent infinite retry loops. Retries are counted per job per commit—if the same job fails again on a new commit, the counter resets.
1. Datadog records the retry outcome on the original pipeline in CI/CD Optimization.

**Note**: Retry behavior depends on the provider (see Provider-specific behavior). On Azure Pipelines, Datadog retries a stage instead of a single job: each stage at most once, and only if every failed job in the stage is classified as retriable.

To see the jobs Datadog retried, open [**CI/CD Optimization** > **Executions**](https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob%20%40ci.job.retry_reason%3Aauto_retry), filtered on `@ci.job.retry_reason:auto_retry`.

## Prerequisites{% #prerequisites %}

To use automatic job retries:

- CI Visibility must be enabled for your [GitHub Actions](https://docs.datadoghq.com/continuous_integration/pipelines/github.md), [GitLab](https://docs.datadoghq.com/continuous_integration/pipelines/gitlab.md), or [Azure Pipelines](https://docs.datadoghq.com/continuous_integration/pipelines/azure.md) integration.
- For GitHub Actions, the [Datadog GitHub App](https://docs.datadoghq.com/continuous_integration/pipelines/github.md#configure-a-github-app) must have the **Actions: Write** permission.
- For Azure Pipelines, your Azure DevOps organization must be connected through the [Azure DevOps Source Code integration](https://docs.datadoghq.com/integrations/azure-devops-source-code.md). The integration's service principal must have the **Queue builds** permission for the project's pipelines. Without this permission, Azure DevOps rejects the retry. To grant it, see [Set pipeline permissions](https://learn.microsoft.com/en-us/azure/devops/pipelines/policies/permissions?view=azure-devops#set-pipeline-permissions-in-azure-pipelines) in the Azure DevOps documentation.
- The [Datadog Source Code Integration](https://docs.datadoghq.com/integrations/guide/source-code-integration.md) must be configured for the repositories where you'd like to use automatic retries.
- Logs Analysis must be configured for the repositories where you'd like to use automatic retries (see [Logs Analysis for GitHub Actions](https://docs.datadoghq.com/continuous_integration/pipelines/github.md#logs-analysis), [Logs Analysis for GitLab](https://docs.datadoghq.com/continuous_integration/pipelines/gitlab.md#logs-analysis), or [Logs Analysis for Azure Pipelines](https://docs.datadoghq.com/continuous_integration/pipelines/azure.md#logs-analysis)).
- To enable this feature, you must have the **CI Provider Settings Write** permission in Datadog.

## Enable automatic job retries{% #enable-automatic-job-retries %}

After the prerequisites are met, enable automatic job retries from CI/CD Optimization settings:

1. Open [**CI/CD Optimization** > **Settings** > **Repositories**](https://app.datadoghq.com/ci/settings/ci-cd/repositories).
1. Choose where to apply the setting:
   - Select the **Organization** tab to enable Auto Job Retries for every repository by default.
   - Select the **Repository-specific** tab to enable Auto Job Retries for a single repository. To apply to many repositories at once, select them and use **Bulk Apply Settings**.
1. Under **Mitigation**, toggle **Auto Job Retries** on.

{% image
   source="https://docs.dd-static.net/images/continuous_integration/auto_job_retries_settings.ec4b18a6195f8e6723d658a0bcbb09c5.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/continuous_integration/auto_job_retries_settings.ec4b18a6195f8e6723d658a0bcbb09c5.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Auto Job Retries toggle in CI/CD Settings." /%}

## Provider-specific behavior{% #provider-specific-behavior %}

{% tab title="GitHub Actions" %}
### GitHub Actions automatic job retries{% #github-actions-automatic-job-retries %}

GitHub Actions imposes two provider-level limitations that shape how retries work:

- **Retries happen after the workflow finishes.** The GitHub API does not allow retrying an individual job while the rest of the workflow is still running. Datadog waits for the workflow to reach a final state before issuing retries.
- **All failed jobs are retried together, even those classified as non-retriable.** The GitHub API does not support retrying a single job when other jobs in the workflow have also failed. Datadog reruns every failed job in the workflow through a single GitHub API call. This may increase your GitHub Actions compute usage.

To see the jobs Datadog retried on GitHub Actions, open [**CI/CD Optimization** > **Executions**](https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob%20%40ci.provider.name%3Agithub%20%40ci.job.retry_reason%3Aauto_retry).

### Protected branches{% #protected-branches %}

The Datadog GitHub App's default permissions do not allow retries on protected branches. To enable automatic retries on a protected branch (for example, your default branch), grant the app org-wide Maintainer-level access. Review your organization's policies before expanding permissions.
{% /tab %}

{% tab title="GitLab" %}
### GitLab automatic job retries{% #gitlab-automatic-job-retries %}

As soon as a job fails in GitLab, Datadog re-runs that specific job (if it is classified as retriable). Other failed jobs (that aren't classified as retriable) and passing jobs aren't affected. There is no additional CI cost beyond the retried job(s).

Automatic job retries works for both SaaS (GitLab.com) and self-hosted GitLab instances.

To see the jobs Datadog retried on GitLab, open [**CI/CD Optimization** > **Executions**](https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob%20%40ci.provider.name%3Agitlab%20%40ci.job.retry_reason%3Aauto_retry).
{% /tab %}

{% tab title="Azure Pipelines" %}
### Azure Pipelines automatic job retries{% #azure-pipelines-automatic-job-retries %}

On Azure Pipelines, Datadog retries stages instead of individual jobs:

- **Datadog retries the stage that contains the failed jobs.** Azure Pipelines re-runs only the failed jobs in that stage. Jobs that passed are not re-run.
- **Every failed job in the stage must be retriable.** If any failed job in the stage is classified as non-retriable, Datadog does not retry the stage.
- **Retries happen after the pipeline run finishes.** Datadog waits for the run to reach a final state before it retries a stage.
- **Datadog retries each stage at most once.** If the retried jobs fail again, Datadog does not retry the stage a second time.

After a retry, the Azure DevOps UI still shows the run's original requester and does not indicate that Datadog retried the stage. To see the jobs Datadog retried on Azure Pipelines, open [**CI/CD Optimization** > **Executions**](https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob%20%40ci.provider.name%3Aazurepipelines%20%40ci.job.retry_reason%3Aauto_retry).
{% /tab %}

## When is a failed job not retried?{% #when-is-a-failed-job-not-retried %}

A failed job is not retried when:

- The AI classifier categorizes the failure as non-retriable (for example, compilation errors or asserted test failures).
- The job has already been retried manually or by provider-native retry rules.
- On Azure Pipelines, the stage has already been retried, or another failed job in the same stage is classified as non-retriable.

**Note:** On GitHub Actions, non-retriable failed jobs may still be re-run if another job in the same workflow is classified as retriable. Datadog issues a single "rerun failed jobs" GitHub API call, which re-runs every failed job in the workflow—including non-retriable ones.

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Explore Pipeline Execution Results and Performance](https://docs.datadoghq.com/continuous_integration/pipelines.md)
- [Set up CI Visibility for GitHub Actions](https://docs.datadoghq.com/continuous_integration/pipelines/github.md)
- [Set up CI Visibility for GitLab](https://docs.datadoghq.com/continuous_integration/pipelines/gitlab.md)
- [Set up CI Visibility for Azure Pipelines](https://docs.datadoghq.com/continuous_integration/pipelines/azure.md)
- [Troubleshooting CI Visibility](https://docs.datadoghq.com/continuous_integration/troubleshooting.md)
