GoogleCloudbuildTrigger class final
Factory wrapper for google_cloudbuild_trigger (provider
hashicorp/google ~> 7.0).
A Cloud Build trigger fires a build in response to a source event (SCM push / pull request, Pub/Sub message, webhook, or manual run). The resource has two competing repository-connection forms that callers must pick between:
- v1 (legacy) — point the trigger at a GitHub App / Bitbucket
Server installation directly via the inline
githuborbitbucketServerTriggerConfigblock. The trigger watches the SCM webhook delivered through the legacy Cloud Build first-party integration. Recommended only for installs that pre-date the second-generation connection (i.e. existing GitHub App users). - v2 (modern, 2024+) — supply
repositoryEventConfigreferring to acloudbuildv2_repository(which in turn pins acloudbuildv2_connection). The v2 form supports the full matrix of providers — GitHub, GitHub Enterprise, GitLab Self-Managed, Bitbucket Data Center, Bitbucket Cloud — through a single uniform Repo API surface. Recommended for new builds.
Each trigger picks exactly one of: github / bitbucketServerTriggerConfig
/ repositoryEventConfig / developerConnectEventConfig /
pubsubConfig / webhookConfig / triggerTemplate / sourceToBuild.
The first six wire up an event source; triggerTemplate is the
legacy Cloud Source Repositories form; sourceToBuild declares a
manual / Pub/Sub / Webhook-invoked build's source explicitly.
Build content is supplied in one of three ways (exactly one):
filename— path to an in-repocloudbuild.yaml. Use withtriggerTemplateorgithub.gitFileSource— fetch the build config from an arbitrary repo / ref. Use with Pub/Sub, Webhook, Manual, or v2 triggers.build— inline build steps + options, fully defined in HCL.
Required identity:
localName: Terraform local name (the address segment aftergoogle_cloudbuild_trigger.).
Optional but commonly set:
location: Cloud Build region (e.g.'asia-northeast1'). Defaults to'global'. Repository-event triggers MUST live in the same region as theircloudbuildv2_repository.name: trigger name (must be unique within the project). When omitted the API assigns one.service_account: Cloud Build service account to run the build as. Format:'projects/{PROJECT_ID}/serviceAccounts/{SA_EMAIL}'. Whennullthe legacy[PROJECT_NUM]@cloudbuild.gserviceaccount.comSA is used.
Example 1 — v1 form (GitHub App push to main, runs in-repo
cloudbuild.yaml):
final pushTrigger = GoogleCloudbuildTrigger(
localName: 'push_main',
name: TfArg.literal('push-main'),
location: TfArg.literal('asia-northeast1'),
filename: TfArg.literal('cloudbuild.yaml'),
github: const CloudBuildTriggerGithub(
owner: TfArg.literal('myorg'),
name: TfArg.literal('my-repo'),
push: CloudBuildTriggerPushFilter(
branch: TfArg.literal('^main\$'),
),
),
);
Example 2 — v2 form (Repository event config, pull-request gate
against a cloudbuildv2_repository sibling — controller wires the
real id at quickstart-materialize time):
final prTrigger = GoogleCloudbuildTrigger(
localName: 'pr_gate',
name: TfArg.literal('pr-gate'),
location: TfArg.literal('asia-northeast1'),
serviceAccount: TfArg.literal(
'projects/my-project/serviceAccounts/cb-runner@my-project.iam.gserviceaccount.com',
),
filename: TfArg.literal('cloudbuild.yaml'),
repositoryEventConfig: CloudBuildTriggerRepositoryEventConfig(
repository: TfArg.literal(r'${var.cloudbuildv2_repository_id}'),
pullRequest: const CloudBuildTriggerPullRequestFilter(
branch: TfArg.literal('^main\$'),
commentControl: TfArg.literal(
CloudBuildTriggerCommentControl.commentsEnabled,
),
),
),
);
Naming convention: ALL nested helper types are prefixed
CloudBuildTrigger... (e.g. CloudBuildTriggerGithub,
CloudBuildTriggerPushFilter, CloudBuildTriggerBuild,
CloudBuildTriggerBuildStep) to avoid colliding with sibling
resources such as GoogleCloudbuildWorkerPool.
The build sub-tree is sprawling — the schema reaches several
levels deep through source.repo_source.substitutions,
step.volumes, artifacts.maven_artifacts, available_secrets,
etc. The wrapper models the commonly-used surface as typed helpers
(CloudBuildTriggerBuild, CloudBuildTriggerBuildStep,
CloudBuildTriggerBuildOptions) and exposes the deeper / rarely-set
sub-blocks via the CloudBuildTriggerBuild.advancedExtra escape
hatch — pass a raw Map<String, Object?> keyed by the Terraform
block name when you need them. See the per-class doc for the exact
escape-hatch key.
Cross-resource references:
build.options.poolaccepts agoogle_cloudbuild_worker_poolid (typically passed asvar.cloudbuild_worker_pool_idfrom a sibling GoogleCloudbuildWorkerPool).repositoryEventConfig.repositoryaccepts agoogle_cloudbuildv2_repositoryid (typically passed asvar.cloudbuildv2_repository_id).
Composition pattern: extends Resource<$GoogleCloudbuildTrigger>
for runtime behavior.
Constructors
-
GoogleCloudbuildTrigger({required String localName, TfArg<
String> ? name, TfArg<String> ? location, TfArg<String> ? description, TfArg<List< ? tags, TfArg<String> >bool> ? disabled, TfArg<String> ? serviceAccount, TfArg<CloudBuildTriggerIncludeBuildLogs> ? includeBuildLogs, TfArg<String> ? filter, TfArg<Map< ? substitutions, TfArg<String, String> >List< ? includedFiles, TfArg<String> >List< ? ignoredFiles, TfArg<String> >String> ? filename, CloudBuildTriggerGitFileSource? gitFileSource, CloudBuildTriggerSourceToBuild? sourceToBuild, CloudBuildTriggerTriggerTemplate? triggerTemplate, CloudBuildTriggerGithub? github, CloudBuildTriggerBitbucketServerTriggerConfig? bitbucketServerTriggerConfig, CloudBuildTriggerRepositoryEventConfig? repositoryEventConfig, CloudBuildTriggerDeveloperConnectEventConfig? developerConnectEventConfig, CloudBuildTriggerPubsubConfig? pubsubConfig, CloudBuildTriggerWebhookConfig? webhookConfig, CloudBuildTriggerApprovalConfig? approvalConfig, CloudBuildTriggerBuild? build, TfArg<String> ? project, LifecycleOptions? lifecycle, List<DependencyTarget> ? dependsOn})
Properties
-
$sensitiveFields
→ Set<
String> -
Field names that are
@Sensitiveper the IR-derived per-resource constant. Curated factories override with a baked-instatic const Set<String>(file-private in v0.5+).no setter -
argMap
→ Map<
String, TfArg?> -
Argument-name → TfArg map. Keys are snake_case (Terraform JSON name).
Synth emits these keys directly; the factory is responsible for the
camelCase → snake_case translation at construction time.
finalinherited
-
createTime
→ TfRef<
String> -
Reference to the
create_timeattribute (RFC 3339 timestamp). Populated after apply.no setter -
dependsOn
→ List<
DependencyTarget> ? -
Optional
depends_on = [...]. Each entry is aDependencyTarget— either a wholesale resource (rendered as bare address) or an explicitTfRef(rendered viabareAddress).finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
→ TfRef<
String> -
Reference to
idattribute. The id format isprojects/{project}/locations/{location}/triggers/{trigger_id}for regional triggers, orprojects/{project}/triggers/{trigger_id}for the legacygloballocation.no setter - kind → ResourceKind
-
Always
ResourceKind.resource. Overridden byData.no setterinherited - lifecycle → LifecycleOptions?
-
Optional
lifecycle { ... }block.finalinherited - localName → String
-
User-supplied local name within a Stack.
finalinherited
-
nameRef
→ TfRef<
String> -
Reference to
nameattribute.no setter - provider → ProviderBinding?
-
Optional explicit provider binding. Only the type is referenced here;
the concrete
Providerclass lives interradart_google(provider classes are defined per-provider, outside the core runtime).finalinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- terraformType → String
-
Terraform resource type, e.g.
google_pubsub_topic.finalinherited - tfAddress → String
-
no setterinherited
-
triggerId
→ TfRef<
String> -
Reference to the server-assigned
trigger_id— the stable identifier in the API path. Populated after apply.no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited