REST Resource: projects.locations.triggers

Resource: BuildTrigger

Configuration for an automated build in response to source repository changes.

JSON representation
{
  "resourceName": string,
  "id": string,
  "description": string,
  "name": string,
  "tags": [
    string
  ],
  "triggerTemplate": {
    object (RepoSource)
  },
  "github": {
    object (GitHubEventsConfig)
  },
  "pubsubConfig": {
    object (PubsubConfig)
  },
  "webhookConfig": {
    object (WebhookConfig)
  },
  "createTime": string,
  "disabled": boolean,
  "substitutions": {
    string: string,
    ...
  },
  "ignoredFiles": [
    string
  ],
  "includedFiles": [
    string
  ],
  "sourceToBuild": {
    object (GitRepoSource)
  },
  "approvalConfig": {
    object (ApprovalConfig)
  },
  "filter": string,
  "serviceAccount": string,

  // Union field build_template can be only one of the following:
  "autodetect": boolean,
  "build": {
    object (Build)
  },
  "filename": string,
  "gitFileSource": {
    object (GitFileSource)
  }
  // End of list of possible types for union field build_template.
}
Fields
resourceName

string

The Trigger name with format: projects/{project}/locations/{location}/triggers/{trigger}, where {trigger} is a unique identifier generated by the service.

id

string

Output only. Unique identifier of the trigger.

description

string

Human-readable description of this trigger.

name

string

User-assigned name of the trigger. Must be unique within the project. Trigger names must meet the following requirements:

  • They must contain only alphanumeric characters and dashes.
  • They can be 1-64 characters long.
  • They must begin and end with an alphanumeric character.
tags[]

string

Tags for annotation of a BuildTrigger

triggerTemplate

object (RepoSource)

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.

Mutually exclusive with github.

github

object (GitHubEventsConfig)

GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received.

Mutually exclusive with triggerTemplate.

pubsubConfig

object (PubsubConfig)

PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.

webhookConfig

object (WebhookConfig)

WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.

createTime

string (Timestamp format)

Output only. Time when the trigger was created.

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

disabled

boolean

If true, the trigger will never automatically execute a build.

substitutions

map (key: string, value: string)

Substitutions for Build resource. The keys must match the following regular expression: ^_[A-Z0-9_]+$.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

ignoredFiles[]

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.

includedFiles[]

string

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.

sourceToBuild

object (GitRepoSource)

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.

approvalConfig

object (ApprovalConfig)

Configuration for manual approval to start a build invocation of this BuildTrigger.

filter

string

A Common Expression Language string.

serviceAccount

string

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. Format: projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT_ID_OR_EMAIL}

Union field build_template. Template describing the Build request to make when the trigger is matched. build_template can be only one of the following:
autodetect

boolean

Autodetect build configuration. The following precedence is used (case insensitive):

  1. cloudbuild.yaml
  2. cloudbuild.yml
  3. cloudbuild.json
  4. Dockerfile

Currently only available for GitHub App Triggers.

build

object (Build)

Contents of the build template.

filename

string

Path, from the source root, to the build configuration file (i.e. cloudbuild.yaml).

gitFileSource

object (GitFileSource)

The file source describing the local or remote Build template.

GitHubEventsConfig

GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received.

JSON representation
{
  "installationId": string,
  "owner": string,
  "name": string,
  "enterpriseConfigResourceName": string,

  // Union field event can be only one of the following:
  "pullRequest": {
    object (PullRequestFilter)
  },
  "push": {
    object (PushFilter)
  }
  // End of list of possible types for union field event.
}
Fields
installationId
(deprecated)

string (int64 format)

The installationID that emits the GitHub event.

owner

string

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

name

string

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

enterpriseConfigResourceName

string

Optional. The resource name of the github enterprise config that should be applied to this installation. For example: "projects/{$projectId}/githubEnterpriseConfigs/{$configId}"

Union field event. Filter describing the types of events to trigger a build. Currently supported event types: push, pull_request. event can be only one of the following:
pullRequest

object (PullRequestFilter)

filter to match changes in pull requests.

push

object (PushFilter)

filter to match changes in refs like branches, tags.

PullRequestFilter

PullRequestFilter contains filter properties for matching GitHub Pull Requests.

JSON representation
{
  "commentControl": enum (CommentControl),
  "invertRegex": boolean,
  "branch": string
}
Fields
commentControl

enum (CommentControl)

Configure builds to run whether a repository owner or collaborator need to comment /gcbrun.

invertRegex

boolean

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

branch

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

CommentControl

Controls behavior of Pull Request comments.

Enums
COMMENTS_DISABLED Do not require comments on Pull Requests before builds are triggered.
COMMENTS_ENABLED Enforce that repository owners or collaborators must comment on Pull Requests before builds are triggered.
COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY Enforce that repository owners or collaborators must comment on external contributors' Pull Requests before builds are triggered.

PushFilter

Push contains filter properties for matching GitHub git pushes.

JSON representation
{
  "invertRegex": boolean,

  // Union field git_ref can be only one of the following:
  "branch": string,
  "tag": string
  // End of list of possible types for union field git_ref.
}
Fields
invertRegex

boolean

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

Union field git_ref. Modified refs to match. A modified refs are the refs modified by a git push operation. git_ref can be only one of the following:
branch

string

Regexes matching branches to build.

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

tag

string

Regexes matching tags to build.

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

PubsubConfig

PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.

JSON representation
{
  "subscription": string,
  "topic": string,
  "serviceAccountEmail": string,
  "state": enum (State)
}
Fields
subscription

string

Output only. Name of the subscription. Format is projects/{project}/subscriptions/{subscription}.

topic

string

The name of the topic from which this subscription is receiving messages. Format is projects/{project}/topics/{topic}.

serviceAccountEmail

string

Service account that will make the push request.

state

enum (State)

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

State

Enumerates potential issues with the underlying Pub/Sub subscription configuration.

Enums
STATE_UNSPECIFIED The subscription configuration has not been checked.
OK The Pub/Sub subscription is properly configured.
SUBSCRIPTION_DELETED The subscription has been deleted.
TOPIC_DELETED The topic has been deleted.
SUBSCRIPTION_MISCONFIGURED Some of the subscription's field are misconfigured.

WebhookConfig

WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.

JSON representation
{
  "state": enum (State),
  "secret": string
}
Fields
state

enum (State)

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

secret

string

Required. Resource name for the secret required as a URL parameter.

State

Enumerates potential issues with the Secret Manager secret provided by the user.

Enums
STATE_UNSPECIFIED The webhook auth configuration not been checked.
OK The auth configuration is properly setup.
SECRET_DELETED The secret provided in auth_method has been deleted.

GitFileSource

GitFileSource describes a file within a (possibly remote) code repository.

JSON representation
{
  "path": string,
  "uri": string,
  "repoType": enum (RepoType),
  "revision": string
}
Fields
path

string

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

uri

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.

repoType

enum (RepoType)

See RepoType above.

revision

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.

RepoType

The type of the repo, since it may not be explicit from the repo field (e.g from a URL).

Enums
UNKNOWN The default, unknown repo type.
CLOUD_SOURCE_REPOSITORIES A Google Cloud Source Repositories-hosted repo.
GITHUB A GitHub-hosted repo not necessarily on "github.com" (i.e. GitHub Enterprise).

GitRepoSource

GitRepoSource describes a repo and ref of a code repository.

JSON representation
{
  "uri": string,
  "ref": string,
  "repoType": enum (RepoType)
}
Fields
uri

string

The URI of the repo (required).

ref

string

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

repoType

enum (RepoType)

See RepoType below.

Methods

create

Creates a new BuildTrigger.

delete

Deletes a BuildTrigger by its project ID and trigger ID.

get

Returns information about a BuildTrigger.

list

Lists existing BuildTriggers.

patch

Updates a BuildTrigger by its project ID and trigger ID.

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.