For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 gcloud commands the step runs during a deployment.


Before you begin


Step YAML

- name: Google Cloud Run Deploy
  id: googleCloudRunDeployStep
  template:
    uses: googleCloudRunDeployStep

The 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

Field
Default value
Description

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

Field
Default value
Description

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

Field
Default value
Description

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.

Skip Traffic Update on first deployment

Skip Traffic Update applies to subsequent deployments only. On the first deployment of a service, Harness always shifts traffic to the new revision regardless of this setting.


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.

Output key
Rollback expression
Description

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:

  1. 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 via gcloud auth list.

  2. Configures the gcloud environment:

  3. Extracts the service name from the manifest and saves it to step output as SERVICE.

  4. Injects the container image URL from the artifact source into the manifest at /harness/manifest/GoogleCloudRun/ServiceManifest.yaml.

  5. 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.

  6. Runs gcloud run services describe <service> --format json to capture the resulting revision name and traffic state.

  7. Saves the revision name and traffic distribution as REVISION_METADATA to step output. For example:

  8. 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.

  9. Publishes INSTANCES and DEPLOYMENT_METADATA to step output.


Next steps

Last updated

Was this helpful?