CloudBuildTrigger


Property Value
Google Cloud Service Name Cloud Build
Google Cloud Service Documentation /cloud-build/docs/
Google Cloud REST Resource Name v1.projects.triggers
Google Cloud REST Resource Documentation /cloud-build/docs/reference/rest/v1/projects.triggers
Config Connector Resource Short Names gcpcloudbuildtrigger
gcpcloudbuildtriggers
cloudbuildtrigger
Config Connector Service Name cloudbuild.googleapis.com
Config Connector Resource Fully Qualified Name cloudbuildtriggers.cloudbuild.cnrm.cloud.google.com
Can Be Referenced by IAMPolicy/IAMPolicyMember No
Config Connector Default Average Reconcile Interval In Seconds 600

Custom Resource Definition Properties

Annotations

Fields
cnrm.cloud.google.com/project-id
cnrm.cloud.google.com/state-into-spec

Spec

Schema

approvalConfig:
  approvalRequired: boolean
bitbucketServerTriggerConfig:
  bitbucketServerConfigResourceRef:
    external: string
    name: string
    namespace: string
  projectKey: string
  pullRequest:
    branch: string
    commentControl: string
    invertRegex: boolean
  push:
    branch: string
    invertRegex: boolean
    tag: string
  repoSlug: string
build:
  artifacts:
    images:
    - string
    objects:
      location: string
      paths:
      - string
      timing:
      - endTime: string
        startTime: string
  availableSecrets:
    secretManager:
    - env: string
      versionRef:
        external: string
        name: string
        namespace: string
  images:
  - string
  logsBucketRef:
    external: string
    name: string
    namespace: string
  options:
    diskSizeGb: integer
    dynamicSubstitutions: boolean
    env:
    - string
    logStreamingOption: string
    logging: string
    machineType: string
    requestedVerifyOption: string
    secretEnv:
    - string
    sourceProvenanceHash:
    - string
    substitutionOption: string
    volumes:
    - name: string
      path: string
    workerPool: string
  queueTtl: string
  secret:
  - kmsKeyRef:
      external: string
      name: string
      namespace: string
    secretEnv:
      string: string
  source:
    repoSource:
      branchName: string
      commitSha: string
      dir: string
      invertRegex: boolean
      projectId: string
      repoRef:
        external: string
        name: string
        namespace: string
      substitutions:
        string: string
      tagName: string
    storageSource:
      bucketRef:
        external: string
        name: string
        namespace: string
      generation: string
      object: string
  step:
  - allowExitCodes:
    - integer
    allowFailure: boolean
    args:
    - string
    dir: string
    entrypoint: string
    env:
    - string
    id: string
    name: string
    script: string
    secretEnv:
    - string
    timeout: string
    timing: string
    volumes:
    - name: string
      path: string
    waitFor:
    - string
  substitutions:
    string: string
  tags:
  - string
  timeout: string
description: string
disabled: boolean
filename: string
filter: string
gitFileSource:
  bitbucketServerConfigRef:
    external: string
    name: string
    namespace: string
  githubEnterpriseConfigRef:
    external: string
    name: string
    namespace: string
  path: string
  repoType: string
  repositoryRef:
    external: string
    name: string
    namespace: string
  revision: string
  uri: string
github:
  enterpriseConfigResourceNameRef:
    external: string
    name: string
    namespace: string
  name: string
  owner: string
  pullRequest:
    branch: string
    commentControl: string
    invertRegex: boolean
  push:
    branch: string
    invertRegex: boolean
    tag: string
ignoredFiles:
- string
includeBuildLogs: string
includedFiles:
- string
location: string
pubsubConfig:
  serviceAccountRef:
    external: string
    name: string
    namespace: string
  state: string
  subscription: string
  topicRef:
    external: string
    name: string
    namespace: string
repositoryEventConfig:
  pullRequest:
    branch: string
    commentControl: string
    invertRegex: boolean
  push:
    branch: string
    invertRegex: boolean
    tag: string
  repository: string
serviceAccountRef:
  external: string
  name: string
  namespace: string
sourceToBuild:
  bitbucketServerConfigRef:
    external: string
    name: string
    namespace: string
  githubEnterpriseConfigRef:
    external: string
    name: string
    namespace: string
  ref: string
  repoType: string
  repositoryRef:
    external: string
    name: string
    namespace: string
  uri: string
substitutions:
  string: string
tags:
- string
triggerTemplate:
  branchName: string
  commitSha: string
  dir: string
  invertRegex: boolean
  repoRef:
    external: string
    name: string
    namespace: string
  tagName: string
webhookConfig:
  secretRef:
    external: string
    name: string
    namespace: string
  state: string
Fields

approvalConfig

Optional

object

Configuration for manual approval to start a build invocation of this BuildTrigger. Builds created by this trigger will require approval before they execute. Any user with a Cloud Build Approver role for the project can approve a build.

approvalConfig.approvalRequired

Optional

boolean

Whether or not approval is needed. If this is set on a build, it will become pending when run, and will need to be explicitly approved to start.

bitbucketServerTriggerConfig

Optional

object

BitbucketServerTriggerConfig describes the configuration of a trigger that creates a build whenever a Bitbucket Server event is received.

bitbucketServerTriggerConfig.bitbucketServerConfigResourceRef

Required*

object

Only `external` field is supported to configure the reference. The full resource name of the bitbucket server config. Format: projects/{project}/locations/{location}/bitbucketServerConfigs/{id}.

bitbucketServerTriggerConfig.bitbucketServerConfigResourceRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildBitbucketServerConfig` resource.

bitbucketServerTriggerConfig.bitbucketServerConfigResourceRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

bitbucketServerTriggerConfig.bitbucketServerConfigResourceRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

bitbucketServerTriggerConfig.projectKey

Required*

string

Key of the project that the repo is in. For example: The key for https://mybitbucket.server/projects/TEST/repos/test-repo is "TEST".

bitbucketServerTriggerConfig.pullRequest

Optional

object

Filter to match changes in pull requests.

bitbucketServerTriggerConfig.pullRequest.branch

Required*

string

Regex of branches to match. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

bitbucketServerTriggerConfig.pullRequest.commentControl

Optional

string

Configure builds to run whether a repository owner or collaborator need to comment /gcbrun. Possible values: ["COMMENTS_DISABLED", "COMMENTS_ENABLED", "COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY"].

bitbucketServerTriggerConfig.pullRequest.invertRegex

Optional

boolean

If true, branches that do NOT match the git_ref will trigger a build.

bitbucketServerTriggerConfig.push

Optional

object

Filter to match changes in refs like branches, tags.

bitbucketServerTriggerConfig.push.branch

Optional

string

Regex of branches to match. Specify only one of branch or tag.

bitbucketServerTriggerConfig.push.invertRegex

Optional

boolean

When true, only trigger a build if the revision regex does NOT match the gitRef regex.

bitbucketServerTriggerConfig.push.tag

Optional

string

Regex of tags to match. Specify only one of branch or tag.

bitbucketServerTriggerConfig.repoSlug

Required*

string

Slug of the repository. A repository slug is a URL-friendly version of a repository name, automatically generated by Bitbucket for use in the URL. For example, if the repository name is 'test repo', in the URL it would become 'test-repo' as in https://mybitbucket.server/projects/TEST/repos/test-repo.

build

Optional

object

Contents of the build template. Either a filename or build template must be provided.

build.artifacts

Optional

object

Artifacts produced by the build that should be uploaded upon successful completion of all build steps.

build.artifacts.images

Optional

list (string)

A list of images to be pushed upon the successful completion of all build steps. The images will be pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build is marked FAILURE.

build.artifacts.images[]

Optional

string

build.artifacts.objects

Optional

object

A list of objects to be uploaded to Cloud Storage upon successful completion of all build steps. Files in the workspace matching specified paths globs will be uploaded to the Cloud Storage location using the builder service account's credentials. The location and generation of the uploaded objects will be stored in the Build resource's results field. If any objects fail to be pushed, the build is marked FAILURE.

build.artifacts.objects.location

Optional

string

Cloud Storage bucket and optional object path, in the form "gs://bucket/path/to/somewhere/". Files in the workspace matching any path pattern will be uploaded to Cloud Storage with this location as a prefix.

build.artifacts.objects.paths

Optional

list (string)

Path globs used to match files in the build's workspace.

build.artifacts.objects.paths[]

Optional

string

build.artifacts.objects.timing

Optional

list (object)

Output only. Stores timing information for pushing all artifact objects.

build.artifacts.objects.timing[]

Optional

object

build.artifacts.objects.timing[].endTime

Optional

string

End of time span. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

build.artifacts.objects.timing[].startTime

Optional

string

Start of time span. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

build.availableSecrets

Optional

object

Secrets and secret environment variables.

build.availableSecrets.secretManager

Required*

list (object)

Pairs a secret environment variable with a SecretVersion in Secret Manager.

build.availableSecrets.secretManager[]

Required*

object

build.availableSecrets.secretManager[].env

Required*

string

Environment variable name to associate with the secret. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step.

build.availableSecrets.secretManager[].versionRef

Required*

object

build.availableSecrets.secretManager[].versionRef.external

Optional

string

Allowed value: The `name` field of a `SecretManagerSecretVersion` resource.

build.availableSecrets.secretManager[].versionRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

build.availableSecrets.secretManager[].versionRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

build.images

Optional

list (string)

A list of images to be pushed upon the successful completion of all build steps. The images are pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build status is marked FAILURE.

build.images[]

Optional

string

build.logsBucketRef

Optional

object

Google Cloud Storage bucket where logs should be written. Logs file names will be of the format ${logsBucket}/log-${build_id}.txt.

build.logsBucketRef.external

Optional

string

Allowed value: The `url` field of a `StorageBucket` resource.

build.logsBucketRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

build.logsBucketRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

build.options

Optional

object

Special options for this build.

build.options.diskSizeGb

Optional

integer

Requested disk size for the VM that runs the build. Note that this is NOT "disk free"; some of the space will be used by the operating system and build utilities. Also note that this is the minimum disk size that will be allocated for the build -- the build may run with a larger disk than requested. At present, the maximum disk size is 1000GB; builds that request more than the maximum are rejected with an error.

build.options.dynamicSubstitutions

Optional

boolean

Option to specify whether or not to apply bash style string operations to the substitutions. NOTE this is always enabled for triggered builds and cannot be overridden in the build configuration file.

build.options.env

Optional

list (string)

A list of global environment variable definitions that will exist for all build steps in this build. If a variable is defined in both globally and in a build step, the variable will use the build step value. The elements are of the form "KEY=VALUE" for the environment variable "KEY" being given the value "VALUE".

build.options.env[]

Optional

string

build.options.logStreamingOption

Optional

string

Option to define build log streaming behavior to Google Cloud Storage. Possible values: ["STREAM_DEFAULT", "STREAM_ON", "STREAM_OFF"].

build.options.logging

Optional

string

Option to specify the logging mode, which determines if and where build logs are stored. Possible values: ["LOGGING_UNSPECIFIED", "LEGACY", "GCS_ONLY", "STACKDRIVER_ONLY", "CLOUD_LOGGING_ONLY", "NONE"].

build.options.machineType

Optional

string

Compute Engine machine type on which to run the build.

build.options.requestedVerifyOption

Optional

string

Requested verifiability options. Possible values: ["NOT_VERIFIED", "VERIFIED"].

build.options.secretEnv

Optional

list (string)

A list of global environment variables, which are encrypted using a Cloud Key Management Service crypto key. These values must be specified in the build's Secret. These variables will be available to all build steps in this build.

build.options.secretEnv[]

Optional

string

build.options.sourceProvenanceHash

Optional

list (string)

Requested hash for SourceProvenance. Possible values: ["NONE", "SHA256", "MD5"].

build.options.sourceProvenanceHash[]

Optional

string

build.options.substitutionOption

Optional

string

Option to specify behavior when there is an error in the substitution checks. NOTE this is always set to ALLOW_LOOSE for triggered builds and cannot be overridden in the build configuration file. Possible values: ["MUST_MATCH", "ALLOW_LOOSE"].

build.options.volumes

Optional

list (object)

Global list of volumes to mount for ALL build steps Each volume is created as an empty volume prior to starting the build process. Upon completion of the build, volumes and their contents are discarded. Global volume names and paths cannot conflict with the volumes defined a build step. Using a global volume in a build with only one step is not valid as it is indicative of a build request with an incorrect configuration.

build.options.volumes[]

Optional

object

build.options.volumes[].name

Optional

string

Name of the volume to mount. Volume names must be unique per build step and must be valid names for Docker volumes. Each named volume must be used by at least two build steps.

build.options.volumes[].path

Optional

string

Path at which to mount the volume. Paths must be absolute and cannot conflict with other volume paths on the same build step or with certain reserved volume paths.

build.options.workerPool

Optional

string

Option to specify a WorkerPool for the build. Format projects/{project}/workerPools/{workerPool} This field is experimental.

build.queueTtl

Optional

string

TTL in queue for this build. If provided and the build is enqueued longer than this value, the build will expire and the build status will be EXPIRED. The TTL starts ticking from createTime. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

build.secret

Optional

list (object)

Secrets to decrypt using Cloud Key Management Service.

build.secret[]

Optional

object

build.secret[].kmsKeyRef

Required*

object

KMS crypto key to use to decrypt these envs.

build.secret[].kmsKeyRef.external

Optional

string

Allowed value: The `selfLink` field of a `KMSCryptoKey` resource.

build.secret[].kmsKeyRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

build.secret[].kmsKeyRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

build.secret[].secretEnv

Optional

map (key: string, value: string)

Map of environment variable name to its encrypted value. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step. Values can be at most 64 KB in size. There can be at most 100 secret values across all of a build's secrets.

build.source

Optional

object

The location of the source files to build. One of 'storageSource' or 'repoSource' must be provided.

build.source.repoSource

Optional

object

Location of the source in a Google Cloud Source Repository.

build.source.repoSource.branchName

Optional

string

Regex matching branches to build. Exactly one a of branch name, tag, or commit SHA must be provided. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

build.source.repoSource.commitSha

Optional

string

Explicit commit SHA to build. Exactly one a of branch name, tag, or commit SHA must be provided.

build.source.repoSource.dir

Optional

string

Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.

build.source.repoSource.invertRegex

Optional

boolean

Only trigger a build if the revision regex does NOT match the revision regex.

build.source.repoSource.projectId

Optional

string

ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.

build.source.repoSource.repoRef

Required*

object

The desired Cloud Source Repository. If omitted, "default" is assumed.

build.source.repoSource.repoRef.external

Optional

string

Allowed value: The `name` field of a `SourceRepoRepository` resource.

build.source.repoSource.repoRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

build.source.repoSource.repoRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

build.source.repoSource.substitutions

Optional

map (key: string, value: string)

Substitutions to use in a triggered build. Should only be used with triggers.run.

build.source.repoSource.tagName

Optional

string

Regex matching tags to build. Exactly one a of branch name, tag, or commit SHA must be provided. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

build.source.storageSource

Optional

object

Location of the source in an archive file in Google Cloud Storage.

build.source.storageSource.bucketRef

Required*

object

Google Cloud Storage bucket containing the source.

build.source.storageSource.bucketRef.external

Optional

string

Allowed value: The `name` field of a `StorageBucket` resource.

build.source.storageSource.bucketRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

build.source.storageSource.bucketRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

build.source.storageSource.generation

Optional

string

Google Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.

build.source.storageSource.object

Required*

string

Google Cloud Storage object containing the source. This object must be a gzipped archive file (.tar.gz) containing source to build.

build.step

Required*

list (object)

The operations to be performed on the workspace.

build.step[]

Required*

object

build.step[].allowExitCodes

Optional

list (integer)

Allow this build step to fail without failing the entire build if and only if the exit code is one of the specified codes. If 'allowFailure' is also specified, this field will take precedence.

build.step[].allowExitCodes[]

Optional

integer

build.step[].allowFailure

Optional

boolean

Allow this build step to fail without failing the entire build. If false, the entire build will fail if this step fails. Otherwise, the build will succeed, but this step will still have a failure status. Error information will be reported in the 'failureDetail' field. 'allowExitCodes' takes precedence over this field.

build.step[].args

Optional

list (string)

A list of arguments that will be presented to the step when it is started. If the image used to run the step's container has an entrypoint, the args are used as arguments to that entrypoint. If the image does not define an entrypoint, the first element in args is used as the entrypoint, and the remainder will be used as arguments.

build.step[].args[]

Optional

string

build.step[].dir

Optional

string

Working directory to use when running this step's container. If this value is a relative path, it is relative to the build's working directory. If this value is absolute, it may be outside the build's working directory, in which case the contents of the path may not be persisted across build step executions, unless a 'volume' for that path is specified. If the build specifies a 'RepoSource' with 'dir' and a step with a 'dir', which specifies an absolute path, the 'RepoSource' 'dir' is ignored for the step's execution.

build.step[].entrypoint

Optional

string

Entrypoint to be used instead of the build step image's default entrypoint. If unset, the image's default entrypoint is used.

build.step[].env

Optional

list (string)

A list of environment variable definitions to be used when running a step. The elements are of the form "KEY=VALUE" for the environment variable "KEY" being given the value "VALUE".

build.step[].env[]

Optional

string

build.step[].id

Optional

string

Unique identifier for this build step, used in 'wait_for' to reference this build step as a dependency.

build.step[].name

Required*

string

The name of the container image that will run this particular build step. If the image is available in the host's Docker daemon's cache, it will be run directly. If not, the host will attempt to pull the image first, using the builder service account's credentials if necessary. The Docker daemon's cache will already have the latest versions of all of the officially supported build steps (see https://github.com/GoogleCloudPlatform/cloud-builders for images and examples). The Docker daemon will also have cached many of the layers for some popular images, like "ubuntu", "debian", but they will be refreshed at the time you attempt to use them. If you built an image in a previous build step, it will be stored in the host's Docker daemon's cache and is available to use as the name for a later build step.

build.step[].script

Optional

string

A shell script to be executed in the step. When script is provided, the user cannot specify the entrypoint or args.

build.step[].secretEnv

Optional

list (string)

A list of environment variables which are encrypted using a Cloud Key Management Service crypto key. These values must be specified in the build's 'Secret'.

build.step[].secretEnv[]

Optional

string

build.step[].timeout

Optional

string

Time limit for executing this build step. If not defined, the step has no time limit and will be allowed to continue to run until either it completes or the build itself times out.

build.step[].timing

Optional

string

Output only. Stores timing information for executing this build step.

build.step[].volumes

Optional

list (object)

List of volumes to mount into the build step. Each volume is created as an empty volume prior to execution of the build step. Upon completion of the build, volumes and their contents are discarded. Using a named volume in only one step is not valid as it is indicative of a build request with an incorrect configuration.

build.step[].volumes[]

Optional

object

build.step[].volumes[].name

Required*

string

Name of the volume to mount. Volume names must be unique per build step and must be valid names for Docker volumes. Each named volume must be used by at least two build steps.

build.step[].volumes[].path

Required*

string

Path at which to mount the volume. Paths must be absolute and cannot conflict with other volume paths on the same build step or with certain reserved volume paths.

build.step[].waitFor

Optional

list (string)

The ID(s) of the step(s) that this build step depends on. This build step will not start until all the build steps in 'wait_for' have completed successfully. If 'wait_for' is empty, this build step will start when all previous build steps in the 'Build.Steps' list have completed successfully.

build.step[].waitFor[]

Optional

string

build.substitutions

Optional

map (key: string, value: string)

Substitutions data for Build resource.

build.tags

Optional

list (string)

Tags for annotation of a Build. These are not docker tags.

build.tags[]

Optional

string

build.timeout

Optional

string

Amount of time that this build should be allowed to run, to second granularity. If this amount of time elapses, work on the build will cease and the build status will be TIMEOUT. This timeout must be equal to or greater than the sum of the timeouts for build steps within the build. The expected format is the number of seconds followed by s. Default time is ten minutes (600s).

description

Optional

string

Human-readable description of the trigger.

disabled

Optional

boolean

Whether the trigger is disabled or not. If true, the trigger will never result in a build.

filename

Optional

string

Path, from the source root, to a file whose contents is used for the template. Either a filename or build template must be provided. Set this only when using trigger_template or github. When using Pub/Sub, Webhook or Manual set the file name using git_file_source instead.

filter

Optional

string

A Common Expression Language string. Used only with Pub/Sub and Webhook.

gitFileSource

Optional

object

The file source describing the local or remote Build template.

gitFileSource.bitbucketServerConfigRef

Optional

object

Only `external` field is supported to configure the reference. The full resource name of the bitbucket server config. Format: projects/{project}/locations/{location}/bitbucketServerConfigs/{id}.

gitFileSource.bitbucketServerConfigRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildBitbucketServerConfig` resource.

gitFileSource.bitbucketServerConfigRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

gitFileSource.bitbucketServerConfigRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

gitFileSource.githubEnterpriseConfigRef

Optional

object

Only `external` field is supported to configure the reference. The full resource name of the github enterprise config. Format: projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}.

gitFileSource.githubEnterpriseConfigRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildGithubEnterpriseConfig` resource.

gitFileSource.githubEnterpriseConfigRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

gitFileSource.githubEnterpriseConfigRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

gitFileSource.path

Required*

string

The path of the file, with the repo root as the root of the path.

gitFileSource.repoType

Required*

string

The type of the repo, since it may not be explicit from the repo field (e.g from a URL). Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"].

gitFileSource.repositoryRef

Optional

object

Only `external` field is supported to configure the reference. The fully qualified resource name of the Repo API repository. The fully qualified resource name of the Repo API repository. If unspecified, the repo from which the trigger invocation originated is assumed to be the repo from which to read the specified path.

gitFileSource.repositoryRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildV2Repository` resource.

gitFileSource.repositoryRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

gitFileSource.repositoryRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

gitFileSource.revision

Optional

string

The branch, tag, arbitrary ref, or SHA version of the repo to use when resolving the filename (optional). This field respects the same syntax/resolution as described here: https://git-scm.com/docs/gitrevisions If unspecified, the revision from which the trigger invocation originated is assumed to be the revision from which to read the specified path.

gitFileSource.uri

Optional

string

The URI of the repo (optional). If unspecified, the repo from which the trigger invocation originated is assumed to be the repo from which to read the specified path.

github

Optional

object

Describes the configuration of a trigger that creates a build whenever a GitHub event is received. One of 'trigger_template', 'github', 'pubsub_config' or 'webhook_config' must be provided.

github.enterpriseConfigResourceNameRef

Optional

object

Only `external` field is supported to configure the reference. The full resource name of the github enterprise config. Format: projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}.

github.enterpriseConfigResourceNameRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildGithubEnterpriseConfig` resource.

github.enterpriseConfigResourceNameRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

github.enterpriseConfigResourceNameRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

github.name

Optional

string

Name of the repository. For example: The name for https://github.com/googlecloudplatform/cloud-builders is "cloud-builders".

github.owner

Optional

string

Owner of the repository. For example: The owner for https://github.com/googlecloudplatform/cloud-builders is "googlecloudplatform".

github.pullRequest

Optional

object

filter to match changes in pull requests. Specify only one of 'pull_request' or 'push'.

github.pullRequest.branch

Required*

string

Regex of branches to match.

github.pullRequest.commentControl

Optional

string

Whether to block builds on a "/gcbrun" comment from a repository owner or collaborator. Possible values: ["COMMENTS_DISABLED", "COMMENTS_ENABLED", "COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY"].

github.pullRequest.invertRegex

Optional

boolean

If true, branches that do NOT match the git_ref will trigger a build.

github.push

Optional

object

filter to match changes in refs, like branches or tags. Specify only one of 'pull_request' or 'push'.

github.push.branch

Optional

string

Regex of branches to match. Specify only one of branch or tag.

github.push.invertRegex

Optional

boolean

When true, only trigger a build if the revision regex does NOT match the git_ref regex.

github.push.tag

Optional

string

Regex of tags to match. Specify only one of branch or tag.

ignoredFiles

Optional

list (string)

ignoredFiles and includedFiles are file glob matches using https://golang.org/pkg/path/filepath/#Match extended with support for '**'. If ignoredFiles and changed files are both empty, then they are not used to determine whether or not to trigger a build. If ignoredFiles is not empty, then we ignore any files that match any of the ignored_file globs. If the change has no files that are outside of the ignoredFiles globs, then we do not trigger a build.

ignoredFiles[]

Optional

string

includeBuildLogs

Optional

string

Build logs will be sent back to GitHub as part of the checkrun result. Values can be INCLUDE_BUILD_LOGS_UNSPECIFIED or INCLUDE_BUILD_LOGS_WITH_STATUS Possible values: ["INCLUDE_BUILD_LOGS_UNSPECIFIED", "INCLUDE_BUILD_LOGS_WITH_STATUS"].

includedFiles

Optional

list (string)

ignoredFiles and includedFiles are file glob matches using https://golang.org/pkg/path/filepath/#Match extended with support for '**'. If any of the files altered in the commit pass the ignoredFiles filter and includedFiles is empty, then as far as this filter is concerned, we should trigger the build. If any of the files altered in the commit pass the ignoredFiles filter and includedFiles is not empty, then we make sure that at least one of those files matches a includedFiles glob. If not, then we do not trigger a build.

includedFiles[]

Optional

string

location

Optional

string

Immutable. The [Cloud Build location](https://cloud.google.com/build/docs/locations) for the trigger. If not specified, "global" is used.

pubsubConfig

Optional

object

PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published. One of 'trigger_template', 'github', 'pubsub_config' 'webhook_config' or 'source_to_build' must be provided.

pubsubConfig.serviceAccountRef

Optional

object

Service account that will make the push request.

pubsubConfig.serviceAccountRef.external

Optional

string

Allowed value: The `email` field of an `IAMServiceAccount` resource.

pubsubConfig.serviceAccountRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

pubsubConfig.serviceAccountRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

pubsubConfig.state

Optional

string

Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.

pubsubConfig.subscription

Optional

string

Output only. Name of the subscription.

pubsubConfig.topicRef

Required*

object

The name of the topic from which this subscription is receiving messages.

pubsubConfig.topicRef.external

Optional

string

Allowed value: string of the format `projects/{{project}}/topics/{{value}}`, where {{value}} is the `name` field of a `PubSubTopic` resource.

pubsubConfig.topicRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

pubsubConfig.topicRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

repositoryEventConfig

Optional

object

The configuration of a trigger that creates a build whenever an event from Repo API is received.

repositoryEventConfig.pullRequest

Optional

object

Contains filter properties for matching Pull Requests.

repositoryEventConfig.pullRequest.branch

Optional

string

Regex of branches to match. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

repositoryEventConfig.pullRequest.commentControl

Optional

string

Configure builds to run whether a repository owner or collaborator need to comment '/gcbrun'. Possible values: ["COMMENTS_DISABLED", "COMMENTS_ENABLED", "COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY"].

repositoryEventConfig.pullRequest.invertRegex

Optional

boolean

If true, branches that do NOT match the git_ref will trigger a build.

repositoryEventConfig.push

Optional

object

Contains filter properties for matching git pushes.

repositoryEventConfig.push.branch

Optional

string

Regex of branches to match. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

repositoryEventConfig.push.invertRegex

Optional

boolean

If true, only trigger a build if the revision regex does NOT match the git_ref regex.

repositoryEventConfig.push.tag

Optional

string

Regex of tags to match. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax.

repositoryEventConfig.repository

Optional

string

The resource name of the Repo API resource.

serviceAccountRef

Optional

object

The service account used for all user-controlled operations including triggers.patch, triggers.run, builds.create, and builds.cancel. If no service account is set, then the standard Cloud Build service account ([PROJECT_NUM]@system.gserviceaccount.com) will be used instead. When populating via the external field, the following format is supported: projects/{PROJECT_ID}/serviceAccounts/{SERVICE_ACCOUNT_EMAIL}

serviceAccountRef.external

Optional

string

Allowed value: string of the format `projects/{{project}}/serviceAccounts/{{value}}`, where {{value}} is the `email` field of an `IAMServiceAccount` resource.

serviceAccountRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

serviceAccountRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

sourceToBuild

Optional

object

The repo and ref of the repository from which to build. This field is used only for those triggers that do not respond to SCM events. Triggers that respond to such events build source at whatever commit caused the event. This field is currently only used by Webhook, Pub/Sub, Manual, and Cron triggers. One of 'trigger_template', 'github', 'pubsub_config' 'webhook_config' or 'source_to_build' must be provided.

sourceToBuild.bitbucketServerConfigRef

Optional

object

Only `external` field is supported to configure the reference. The full resource name of the bitbucket server config. Format: projects/{project}/locations/{location}/bitbucketServerConfigs/{id}.

sourceToBuild.bitbucketServerConfigRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildBitbucketServerConfig` resource.

sourceToBuild.bitbucketServerConfigRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

sourceToBuild.bitbucketServerConfigRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

sourceToBuild.githubEnterpriseConfigRef

Optional

object

Only `external` field is supported to configure the reference. The full resource name of the github enterprise config. Format: projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}.

sourceToBuild.githubEnterpriseConfigRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildGithubEnterpriseConfig` resource.

sourceToBuild.githubEnterpriseConfigRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

sourceToBuild.githubEnterpriseConfigRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

sourceToBuild.ref

Required*

string

The branch or tag to use. Must start with "refs/" (required).

sourceToBuild.repoType

Required*

string

The type of the repo, since it may not be explicit from the repo field (e.g from a URL). Values can be UNKNOWN, CLOUD_SOURCE_REPOSITORIES, GITHUB, BITBUCKET_SERVER Possible values: ["UNKNOWN", "CLOUD_SOURCE_REPOSITORIES", "GITHUB", "BITBUCKET_SERVER"].

sourceToBuild.repositoryRef

Optional

object

Only `external` field is supported to configure the reference. The qualified resource name of the Repo API repository. Either uri or repository can be specified and is required.

sourceToBuild.repositoryRef.external

Optional

string

Allowed value: The `name` field of a `CloudBuildV2Repository` resource.

sourceToBuild.repositoryRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

sourceToBuild.repositoryRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

sourceToBuild.uri

Optional

string

The URI of the repo.

substitutions

Optional

map (key: string, value: string)

Substitutions data for Build resource.

tags

Optional

list (string)

Tags for annotation of a BuildTrigger.

tags[]

Optional

string

triggerTemplate

Optional

object

Template describing the types of source changes to trigger a build. Branch and tag names in trigger templates are interpreted as regular expressions. Any branch or tag change that matches that regular expression will trigger a build. One of 'trigger_template', 'github', 'pubsub_config', 'webhook_config' or 'source_to_build' must be provided.

triggerTemplate.branchName

Optional

string

Name of the branch to build. Exactly one a of branch name, tag, or commit SHA must be provided. This field is a regular expression.

triggerTemplate.commitSha

Optional

string

Explicit commit SHA to build. Exactly one of a branch name, tag, or commit SHA must be provided.

triggerTemplate.dir

Optional

string

Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.

triggerTemplate.invertRegex

Optional

boolean

Only trigger a build if the revision regex does NOT match the revision regex.

triggerTemplate.repoRef

Optional

object

The Cloud Source Repository to build. If omitted, the repo with name "default" is assumed.

triggerTemplate.repoRef.external

Optional

string

Allowed value: The `name` field of a `SourceRepoRepository` resource.

triggerTemplate.repoRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

triggerTemplate.repoRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

triggerTemplate.tagName

Optional

string

Name of the tag to build. Exactly one of a branch name, tag, or commit SHA must be provided. This field is a regular expression.

webhookConfig

Optional

object

WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL. One of 'trigger_template', 'github', 'pubsub_config' 'webhook_config' or 'source_to_build' must be provided.

webhookConfig.secretRef

Required*

object

The secret required

webhookConfig.secretRef.external

Optional

string

Allowed value: The `name` field of a `SecretManagerSecretVersion` resource.

webhookConfig.secretRef.name

Optional

string

Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

webhookConfig.secretRef.namespace

Optional

string

Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

webhookConfig.state

Optional

string

Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.

* Field is required when parent field is specified

Status

Schema

conditions:
- lastTransitionTime: string
  message: string
  reason: string
  status: string
  type: string
createTime: string
observedGeneration: integer
triggerId: string
Fields
conditions

list (object)

Conditions represent the latest available observation of the resource's current state.

conditions[]

object

conditions[].lastTransitionTime

string

Last time the condition transitioned from one status to another.

conditions[].message

string

Human-readable message indicating details about last transition.

conditions[].reason

string

Unique, one-word, CamelCase reason for the condition's last transition.

conditions[].status

string

Status is the status of the condition. Can be True, False, Unknown.

conditions[].type

string

Type is the type of the condition.

createTime

string

Time when the trigger was created.

observedGeneration

integer

ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource.

triggerId

string

The unique identifier for the trigger.

Sample YAML(s)

Build Trigger For Cloud Source Repo

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: cloudbuild.cnrm.cloud.google.com/v1beta1
kind: CloudBuildTrigger
metadata:
  name: cloudbuildtrigger-sample-cloudsourcerepo
spec:
  description: Cloud Build Trigger for building the master branch of the referenced Cloud Source Repository.
  disabled: false
  triggerTemplate:
    repoRef:
      name: cloudbuildtrigger-dep-cloudsourcerepo
    dir: "team-a/service-b"
    branchName: master
  ignoredFiles:
    - "**/*.md"
  includedFiles:
    - "src/**"
  substitutions:
    "_SERVICE_NAME": "service-name"
  build:
    # Note: $PROJECT_ID and $COMMIT_SHA are variables that are expanded by the
    # Cloud Build API when the build is created. More info:
    # https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values
    images: ["gcr.io/$PROJECT_ID/${_SERVICE_NAME}:$COMMIT_SHA"]
    tags: ["team-a", "service-b"]
    timeout: 1800s
    step:
      - id: "download_zip"
        name: gcr.io/cloud-builders/gsutil
        args: ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
        timeout: 300s
      - id: "build_package"
        name: gcr.io/cloud-builders/go
        args: ["build", "my_package"]
        dir: directory
        env:
          - "ENV1=one"
          - "ENV2=two"
        secretEnv:
          - "SECRET_ENV1"
        timeout: 300s
      - id: "build_docker_image"
        name: gcr.io/cloud-builders/docker
        args: ["build", "-t", "gcr.io/$PROJECT_ID/${_SERVICE_NAME}:$COMMIT_SHA", "-f", "Dockerfile", "."]
        timeout: 300s
    availableSecrets:
      secretManager:
        - env: SECRET1
          versionRef:
            name: cloudbuildtrigger-dep-cloudsourcerepo
---
apiVersion: secretmanager.cnrm.cloud.google.com/v1beta1
kind: SecretManagerSecret
metadata:
  name: cloudbuildtrigger-dep-cloudsourcerepo
spec:
  replication:
    automatic: true
---
apiVersion: secretmanager.cnrm.cloud.google.com/v1beta1
kind: SecretManagerSecretVersion
metadata:
  name: cloudbuildtrigger-dep-cloudsourcerepo
spec:
  enabled: true
  secretData:
    value: c2VjcmV0MQ==
  secretRef:
    name: cloudbuildtrigger-dep-cloudsourcerepo
---
apiVersion: sourcerepo.cnrm.cloud.google.com/v1beta1
kind: SourceRepoRepository
metadata:
  name: cloudbuildtrigger-dep-cloudsourcerepo

Build Trigger For GitHub Repo

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: cloudbuild.cnrm.cloud.google.com/v1beta1
kind: CloudBuildTrigger
metadata:
  name: cloudbuildtrigger-sample-github
spec:
  # Cloud Build Triggers for GitHub repositories require that you first connect
  # your GCP project to your GitHub repository. More info:
  # https://cloud.google.com/cloud-build/docs/automating-builds/create-github-app-triggers
  description: Cloud Build Trigger for building the master branch of the GitHub repository at github.com/owner_name/repo_name
  disabled: false
  github:
    owner: owner_name
    name: repo_name
    push:
      branch: master
  ignoredFiles:
    - "**/*.md"
  includedFiles:
    - "src/**"
  substitutions:
    "_SERVICE_NAME": "service-name"
  build:
    # Note: $PROJECT_ID and $COMMIT_SHA are variables that are expanded by the
    # Cloud Build API when the build is created. More info:
    # https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values
    images: ["gcr.io/$PROJECT_ID/${_SERVICE_NAME}:$COMMIT_SHA"]
    tags: ["team-a", "service-b"]
    timeout: 1800s
    step:
      - id: "download_zip"
        name: gcr.io/cloud-builders/gsutil
        args: ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
        timeout: 300s
      - id: "build_package"
        name: gcr.io/cloud-builders/go
        args: ["build", "my_package"]
        dir: directory
        env:
          - "ENV1=one"
          - "ENV2=two"
        secretEnv:
          - "SECRET_ENV1"
        timeout: 300s
      - id: "build_docker_image"
        name: gcr.io/cloud-builders/docker
        args: ["build", "-t", "gcr.io/$PROJECT_ID/${_SERVICE_NAME}:$COMMIT_SHA", "-f", "Dockerfile", "."]
        timeout: 300s

Build Trigger With Template File

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: cloudbuild.cnrm.cloud.google.com/v1beta1
kind: CloudBuildTrigger
metadata:
  name: cloudbuildtrigger-sample-withtemplatefile
spec:
  description: Cloud Build Trigger with a build template file. Builds the master branch of the referenced Cloud Source Repository.
  disabled: false
  triggerTemplate:
    repoRef:
      name: cloudbuildtrigger-dep-withtemplatefile
    dir: "team-a/service-b"
    branchName: master
  ignoredFiles:
    - "**/*.md"
  includedFiles:
    - "src/**"
  substitutions:
    "_SERVICE_NAME": "service-name"
  filename: "cloudbuild.yaml"
  serviceAccountRef:
    name: cbt-dep-withtemplatefile
---
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMServiceAccount
metadata:
  name: cbt-dep-withtemplatefile
---
apiVersion: sourcerepo.cnrm.cloud.google.com/v1beta1
kind: SourceRepoRepository
metadata:
  name: cloudbuildtrigger-dep-withtemplatefile