Cloud Build API Connector Overview

The Workflows connector defines the built-in functions that can be used to access other Google Cloud products within a workflow.

This page provides an overview of the individual connector. There is no need to import or load connector libraries in a workflow—connectors work out of the box when used in a call step.

Cloud Build API

Creates and manages builds on Google Cloud Platform. To learn more, see the Cloud Build API documentation.

Cloud Build connector sample

YAML

# This workflow demonstrates how to use the Cloud Build connector.
# The workflow creates a simple build and the image is stored to an Artifact Registery repo.
# The workflow assumes a properly defined source tgz file already
# exists in a Cloud Storage bucket: gs://your-project-id_cloudbuild/source/placeholder_src.tgz
# and a repository "your-project-id-docker-repo" already
# exists in Artifact Registry where the image will be stored.
# The new table and dataset are both deleted in the following steps.
# Expected successful output: "SUCCESS"

- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - location_id: "global"
      - repo: ${project_id + "-docker-repo"}
      - image_path: ${"us-central1-docker.pkg.dev/" + project_id + "/" + repo + "/quickstart-image:tag1"}
- create_build:
    call: googleapis.cloudbuild.v1.projects.builds.create
    args:
      projectId: ${project_id}
      parent: ${"projects/" + project_id + "/locations/" + location_id}
      body:
        source:
          storageSource:
            bucket: ${project_id + "_cloudbuild"}
            object: "source/placeholder_src.tgz"
        steps:
          - name: "gcr.io/cloud-builders/docker"
            args:
              - "build"
              - "-t"
              - ${image_path}
              - "."
        images:
          - ${image_path}
- the_end:
    return: "SUCCESS"

JSON

[
  {
    "init": {
      "assign": [
        {
          "project_id": "${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}"
        },
        {
          "location_id": "global"
        },
        {
          "repo": "${project_id + \"-docker-repo\"}"
        },
        {
          "image_path": "${\"us-central1-docker.pkg.dev/\" + project_id + \"/\" + repo + \"/quickstart-image:tag1\"}"
        }
      ]
    }
  },
  {
    "create_build": {
      "call": "googleapis.cloudbuild.v1.projects.builds.create",
      "args": {
        "projectId": "${project_id}",
        "parent": "${\"projects/\" + project_id + \"/locations/\" + location_id}",
        "body": {
          "source": {
            "storageSource": {
              "bucket": "${project_id + \"_cloudbuild\"}",
              "object": "source/placeholder_src.tgz"
            }
          },
          "steps": [
            {
              "name": "gcr.io/cloud-builders/docker",
              "args": [
                "build",
                "-t",
                "${image_path}",
                "."
              ]
            }
          ],
          "images": [
            "${image_path}"
          ]
        }
      }
    }
  },
  {
    "the_end": {
      "return": "SUCCESS"
    }
  }
]

Module: googleapis.cloudbuild.v1.operations

Functions
cancel Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
get Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Module: googleapis.cloudbuild.v1.projects.builds

Functions
approve Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
cancel Cancels a build in progress.
create Starts a build with the specified configuration. This method returns a long-running Operation, which includes the build ID. Pass the build ID to GetBuild to determine the build status (such as SUCCESS or FAILURE).
get Returns information about a previously requested build. The Build that is returned includes its status (such as SUCCESS, FAILURE, or WORKING), and timing information.
list Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
retry Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify RepoSource: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify StorageSource: If the original build pulled source from Google Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.

Module: googleapis.cloudbuild.v1.projects.githubEnterpriseConfigs

Functions
create Create an association between a GCP project and a GitHub Enterprise server. This API is experimental.
delete Delete an association between a GCP project and a GitHub Enterprise server. This API is experimental.
get Retrieve a GitHubEnterpriseConfig. This API is experimental.
list List all GitHubEnterpriseConfigs for a given project. This API is experimental.
patch Update an association between a GCP project and a GitHub Enterprise server. This API is experimental.

Module: googleapis.cloudbuild.v1.projects.locations.builds

Functions
approve Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
cancel Cancels a build in progress.
create Starts a build with the specified configuration. This method returns a long-running Operation, which includes the build ID. Pass the build ID to GetBuild to determine the build status (such as SUCCESS or FAILURE).
get Returns information about a previously requested build. The Build that is returned includes its status (such as SUCCESS, FAILURE, or WORKING), and timing information.
list Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
retry Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify RepoSource: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify StorageSource: If the original build pulled source from Google Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.

Module: googleapis.cloudbuild.v1.projects.locations.githubEnterpriseConfigs

Functions
create Create an association between a GCP project and a GitHub Enterprise server. This API is experimental.
delete Delete an association between a GCP project and a GitHub Enterprise server. This API is experimental.
get Retrieve a GitHubEnterpriseConfig. This API is experimental.
list List all GitHubEnterpriseConfigs for a given project. This API is experimental.
patch Update an association between a GCP project and a GitHub Enterprise server. This API is experimental.

Module: googleapis.cloudbuild.v1.projects.locations.operations

Functions
cancel Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
get Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Module: googleapis.cloudbuild.v1.projects.locations.triggers

Functions
create Creates a new BuildTrigger. This API is experimental.
delete Deletes a BuildTrigger by its project ID and trigger ID. This API is experimental.
get Returns information about a BuildTrigger. This API is experimental.
list Lists existing BuildTriggers. This API is experimental.
patch Updates a BuildTrigger by its project ID and trigger ID. This API is experimental.
run Runs a BuildTrigger at a particular source revision.
webhook ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.

Module: googleapis.cloudbuild.v1.projects.locations.workerPools

Functions
create Creates a WorkerPool.
delete Deletes a WorkerPool.
get Returns details of a WorkerPool.
list Lists WorkerPools.
patch Updates a WorkerPool.

Module: googleapis.cloudbuild.v1.projects.triggers

Functions
create Creates a new BuildTrigger. This API is experimental.
delete Deletes a BuildTrigger by its project ID and trigger ID. This API is experimental.
get Returns information about a BuildTrigger. This API is experimental.
list Lists existing BuildTriggers. This API is experimental.
patch Updates a BuildTrigger by its project ID and trigger ID. This API is experimental.
run Runs a BuildTrigger at a particular source revision.
webhook ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.