Google Cloud Run Job
Deploy and execute a Cloud Run Job using the Google Cloud Run Job step.
The Google Cloud Run Job step deploys or updates a Cloud Run Job definition and executes it. Use this step for batch workloads, scheduled tasks, and background processing that run to completion rather than serving ongoing requests.
What you will learn
How to configure the Job step to execute an existing job by name or replace the job definition from a manifest.
The two operating modes: execute only (Job Name set) versus replace and execute (Job Name empty).
The
gcloudcommands the step runs for each mode.
Before you begin
A Google Cloud Run infrastructure with a GCP connector and region. Go to Google Cloud Run infrastructure.
A Cloud Run Job manifest (optional). Required only when you want to update the job definition before executing. If you only want to execute an existing job, only the job name is needed.
Add this step using the blank canvas deployment strategy. Go to Blank canvas.
Step YAML
Execute an existing job by name (execute only):
- name: Google Cloud Run Job
id: googleCloudRunJobStep
template:
uses: googleCloudRunJobStep
with:
job_name: my-batch-job
execute_command_options: "--update-env-vars=ENV=production"Replace the job definition from the service manifest, then execute (Job Name empty):
Configure the step
The step operates in one of two modes based on whether Job Name is set. Infrastructure fields are resolved from the stage context when not set explicitly.
Job configuration
Job Name
The name of the Cloud Run job to execute. When set, the step runs execute only (gcloud run jobs execute). Leave empty to replace the job definition from the service manifest first, then execute.
Replace Command Options
Additional flags passed to gcloud run jobs replace (for example, --async --verbosity=debug). Only applies when Job Name is empty. Does not trigger replace on its own.
Execute Command Options
Additional flags passed to gcloud run jobs execute (for example, --update-env-vars=key1=value1).
Infrastructure configuration
GCP Connector, GCP Region, and GCP Project are available under + More options on the step. When not set, Harness resolves these from the infrastructure definition.
GCP Connector
Infrastructure connector
The GCP connector used to authenticate.
GCP Region
${{infra.region}}
The GCP region of the Cloud Run job.
GCP Project
${{infra.project}}
The GCP project.
Advanced settings
Timeout duration: Maximum time the step is allowed to run before being terminated.
On failure: Define what happens if the step fails: retry, mark as success, or abort.
Strategy: Configure a looping strategy to run this step over a list of values.
Conditional execution: Run this step only when a specified condition is true.
How it runs
When the Job step executes, the following sequence occurs:
Authenticates with GCP using the configured connector. For Service Account auth (ManualConfig), runs
gcloud auth activate-service-account --key-file sa_key.json. For Inherit from Delegate, identifies the active account viagcloud auth list.Configures the gcloud environment: sets project and region.
Determines the mode based on Job Name:
Job Name empty: runs
gcloud run jobs replace <manifest>to create or update the job definition from the service manifest. Any flags from Replace Command Options are appended.Job Name set: skips replace.
Runs
gcloud run jobs execute <job-name>to trigger the job execution. Any flags from Execute Command Options are appended to this command.
Next steps
Go to Blank canvas to set up a stage for Cloud Run Job deployments.
Go to Google Cloud Run Deploy for service deployments that use
gcloud run services replaceinstead.
Last updated
Was this helpful?