This page describes how to manage jobs. To create a job, see create jobs. To execute a job, see Execute jobs.
Container image digest and tags for Cloud Run jobs
How you update your job to run the latest version of your code depends on whether you specified a container image with a tag or a digest.
When you create a job, you can specify a container image with a tag, for example,
gcr.io/my-project/my-image:tag
, or with an exact digest, for example,
gcr.io/my-project/my-image@sha256:41f34ab970ee...
. If you do not specify either
of these, the tag :latest
is used.
If you specified a container image with a tag, Cloud Run resolves your image to a specific digest when you execute your job. This means that you don't need to explicitly update your job to pick up the latest version of your container next time you execute your job.
If you instead prefer your job to use a specific container digest every time it executes, you can specify a container image with an exact digest. In this case, you must explicitly update your job to use a different digest if you want your job to pick up code changes you made:
gcloud run jobs update JOB_NAME --image IMAGE_URL
Replace
- JOB_NAME with a lowercase name with no underscores
- IMAGE_URL with a reference to the container image, for
example,
us-docker.pkg.dev/cloudrun/container/job:latest
No matter how you specify your container image, all tasks of an execution will always use the same container image digest.
View jobs in your project
You can view a list of the jobs in your project using the gcloud command line:
Console
To view jobs:
Optionally, filter the job by one of the criteria in the dropdown menu, such as job name, execution time, region, and so on.
Command line
To list all jobs in your project:
gcloud run jobs list
To filter jobs by region:
gcloud run jobs list --region REGION
Replace
REGION
with the name of the region you are filtering on, for exampleus-central1
.
For other ways to refine the returned list, including the use of filters, see jobs list.
Client libraries
To view jobs in your project from code:
REST API
To view the list of jobs in your project, send a GET
HTTP request to
the Cloud Run Admin API jobs
endpoint.
For example, using curl
:
curl -H "Content-Type: application/json" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -X GET \ -d '' \ https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs
Replace:
- ACCESS_TOKEN with a valid access token for an account that
has the IAM permissions to view jobs.
For example, if you are logged into gcloud, you can retrieve an
access token using
gcloud auth print-access-token
. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server. - REGION with the Google Cloud region of the job.
- PROJECT-ID with the Google Cloud project ID.
View job details
Use the gcloud command line to see more details about a job.
Console
To view details for a specific job execution:
Locate the job you are interested in.
Click the job to display the job details page.
Note the History, Configuration, Logs, and YAML tabs.
- The History tab shows information about the tasks in the job execution.
- Logs shows the logs information.
- Configuration shows information about the job, the container, security, connectivity and so forth.
- YAML shows the configuration of the job in YAML format.
Command line
To view details about a job:
Use the command:
gcloud run jobs describe JOB_NAME
Replace JOB_NAME
with the name of the job.
Client libraries
To view details about a job from code:
REST API
To view details about a job, send a GET
HTTP request to
the Cloud Run Admin API jobs
endpoint.
For example, using curl
:
curl -H "Content-Type: application/json" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -X GET \ -d '' \ https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs/JOB-NAME
Replace:
- ACCESS_TOKEN with a valid access token for an account that
has the IAM permissions to view job details.
For example, if you are logged into gcloud, you can retrieve an
access token using
gcloud auth print-access-token
. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server. - JOB-NAME with the name of the job.
- REGION with the Google Cloud region of the job.
- PROJECT-ID with the Google Cloud project ID.
Delete a job
You can delete a job only if there are no job executions of that job currently running.
Although a deleted job no longer appears in the list of jobs, its logs continue to be available in Cloud Logging for the remainder of the log retention period, and monitoring data continues to be available in Cloud Monitoring.
Console
To delete a job:
Select the job.
Click Delete.
Command line
To delete a job:
Use the command:
gcloud run jobs delete JOB_NAME
Replace
JOB_NAME
with the name of the job.If prompted to confirm, respond
y
. Upon success, a success message will be displayed.
Client libraries
To delete a job from code:
REST API
To delete a job, send a DELETE
HTTP request to
the Cloud Run Admin API jobs
endpoint.
For example, using curl
:
curl -H "Content-Type: application/json" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -X DELETE \ -d '' \ https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs/JOB-NAME
Replace:
- ACCESS_TOKEN with a valid access token for an account that
has the IAM permissions to delete jobs.
For example, if you are logged into gcloud, you can retrieve an
access token using
gcloud auth print-access-token
. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server. - JOB-NAME with the name of the job.
- REGION with the Google Cloud region of the job.
- PROJECT-ID with the Google Cloud project ID.