Google Cloud Run Deploy
Apply a Cloud Run service manifest and create a new revision using the Google Cloud Run Deploy step.
The Google Cloud Run Deploy step applies your service manifest to Cloud Run, creates a new revision, and optionally shifts all traffic to it immediately. The step also saves rollback data so Harness can restore the previous revision if the stage fails.
What you will learn
How the Deploy step applies a service manifest and creates a new Cloud Run revision.
Which fields you can override with a
with:block and which are resolved automatically from the stage context.How rollback data is saved so Harness can restore the previous state on failure.
The sequence of
gcloudcommands the step runs during a deployment.
Before you begin
A Google Cloud Run service with a service manifest and artifact source. Go to Google Cloud Run services.
A Google Cloud Run infrastructure with a GCP connector and region. Go to Google Cloud Run infrastructure.
Step YAML
- name: Google Cloud Run Deploy
id: googleCloudRunDeployStep
template:
uses: googleCloudRunDeployStepThe step uses no explicit with: inputs by default; service configuration and infrastructure are resolved from the stage context at runtime.
With explicit overrides:
Configure the step
The following fields appear on the Deploy step. Most values are resolved automatically from the service and infrastructure definition; add a with: block only when you need to override a specific field.
Service configuration
Service Manifest Path
${{runtime.manifestPath}}
Path to the downloaded service manifest. Resolved automatically at runtime.
Service Container Image
${{artifact.image}}
Container image URL from the artifact source. Harness injects this into the manifest before deploying.
Infrastructure configuration
GCP Connector
Infrastructure connector
The GCP connector used to authenticate. Defaults to the connector in the infrastructure definition.
GCP Region
${{infra.region}}
The Cloud Run service region. Resolved from the infrastructure definition.
GCP Project
${{infra.project}}
The GCP project. Resolved from the infrastructure definition.
Deployment options
Command Options
—
Additional flags passed to gcloud run services replace (for example, --port=8080).
Skip Traffic Update
false
When true, creates a new revision without shifting any traffic. Use with a Traffic Shift step to control when traffic moves to the new revision.
Command Timeout
10m
Maximum time the step is allowed to run.
Log Level
info
Log verbosity for the step.
Step outputs
After the step completes, the following values are saved to rollback data and are accessible via ${{rollback.data.<key>}} in the Rollback step.
SERVICE
${{rollback.data.SERVICE}}
The Cloud Run service name.
REVISION_METADATA
${{rollback.data.REVISION_METADATA}}
The post-deploy revision name and traffic state, saved as a JSON string. The Rollback step reads this to identify the revision to restore.
FIRST_DEPLOYMENT
${{rollback.data.FIRST_DEPLOYMENT}}
Whether this was the first deployment of the service. Harness uses this internally to decide between traffic restore and service delete on rollback.
INSTANCES
—
Instance count reported by Google Cloud Monitoring after the deployment.
DEPLOYMENT_METADATA
—
Full deployment metadata for Harness instance tracking.
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 Deploy 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:
Extracts the service name from the manifest and saves it to step output as
SERVICE.Injects the container image URL from the artifact source into the manifest at
/harness/manifest/GoogleCloudRun/ServiceManifest.yaml.Applies the manifest:
gcloud run services replace /harness/manifest/GoogleCloudRun/ServiceManifest.yaml. Cloud Run creates a new revision and, unless Skip Traffic Update is enabled, routes all traffic to it immediately.Runs
gcloud run services describe <service> --format jsonto capture the resulting revision name and traffic state.Saves the revision name and traffic distribution as
REVISION_METADATAto step output. For example:Performs instance sync using the Google Cloud Monitoring SDK with filter:
If no data is available, retries every 60 seconds, up to 10 times. If data is found, waits an additional 60 seconds for a stable read. Factor up to 10 minutes of instance sync into your expected step duration.
Publishes
INSTANCESandDEPLOYMENT_METADATAto step output.
Next steps
Go to Google Cloud Run Traffic Shift to route traffic to a specific revision after deploy.
Go to Google Cloud Run Rollback for the rollback step that restores the previous revision.
Go to Canary deployment for a full walkthrough of the Deploy and Traffic Shift steps together.
Last updated
Was this helpful?