Set maximum retries for jobs

A Cloud Run job consists of one or more tasks. The maximum retriessetting specifies the number of times a task is allowed to restart in case offailure before being failed permanently. The default is3.

This setting applies per-task, not per-job. If you set this to 0, tasks only runonce and are not retried on failure.

Required roles

To get the permissions that you need to configure Cloud Run jobs, ask your administrator to grant you the following IAM roles:

For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run job interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.

Configure maximum retries

To specify maximum retries:

Console

  1. In the Google Cloud console, go to the Cloud RunJobs page:

    Go to Cloud Run

  2. ClickDeploy container to fill outthe initial job settings page. If you are configuring an existing job,select the job, then clickView and edit job configuration.

  3. ClickContainer(s), Volumes, Connections, Security to expand the job properties page.

  4. Click theGeneral tab.

    image

    • Specify the number of retries using an integer from0 to 10.
  5. ClickCreate orUpdate.

gcloud

  1. For a job you are creating:

    gcloudrunjobscreateJOB_NAME--imageIMAGE_URL--max-retriesRETRY

    Replace

    • JOB_NAME with the name of your job.
    • IMAGE_URL: a reference to thecontainer image—forexample,us-docker.pkg.dev/cloudrun/container/job:latest.
    • RETRY with the number of retries: specify an integer from 0 to10.
  2. For a job you are updating:

    gcloudrunjobsupdateJOB_NAME--max-retriesRETRY

YAML

  1. If you are creating a new job, skip this step.If you are updating an existing job, download itsYAML configuration:

    gcloudrunjobsdescribeJOB_NAME--formatexport>job.yaml
  2. Update themaxRetries: attribute:

    apiVersion:run.googleapis.com/v1kind:Jobmetadata:name:JOBspec:template:spec:template:spec:containers:-image:IMAGEmaxRetries:RETRIES

    ReplaceRETRIES with the number of retries: specify an integerfrom0 to10.

    You can also specify more configuration such as environment variables ormemory limits.

  3. Update the existing job configuration:

    gcloudrunjobsreplacejob.yaml

Terraform

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

Add the following to agoogle_cloud_run_v2_job resource in your Terraform configuration:

resource"google_cloud_run_v2_job""default"{name="cloud-run-job-retries"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{template{max_retries=3containers{image="us-docker.pkg.dev/cloudrun/container/job:latest"}}}}

View maximum retries settings

To view the current maximum retries settings for yourCloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run jobs

  2. Click the job you are interested in to open theJob details page.

  3. ClickView and Edit job configuration.

  4. Locate the maximum retries setting in the configurationdetails.

gcloud

  1. Use the following command:

    gcloudrunjobsdescribeJOB_NAME
  2. Locate the maximum retries setting in the returnedconfiguration.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.