...
1/**
2 * Copyright 2022 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17```hcl
18resource "google_cloudbuild_trigger" "build-trigger" {
19 location = "global"
20
21 trigger_template {
22 branch_name = "main"
23 repo_name = "my-repo"
24 }
25
26 build {
27 step {
28 name = "gcr.io/cloud-builders/gsutil"
29 args = ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
30 timeout = "120s"
31 secret_env = ["MY_SECRET"]
32 }
33
34 step {
35 name = "ubuntu"
36 script = "echo hello" # using script field
37 }
38
39 source {
40 storage_source {
41 bucket = "mybucket"
42 object = "source_code.tar.gz"
43 }
44 }
45 tags = ["build", "newFeature"]
46 substitutions = {
47 _FOO = "bar"
48 _BAZ = "qux"
49 }
50 queue_ttl = "20s"
51 logs_bucket = "gs://mybucket/logs"
52 secret {
53 kms_key_name = "projects/myProject/locations/global/keyRings/keyring-name/cryptoKeys/key-name"
54 secret_env = {
55 PASSWORD = "ZW5jcnlwdGVkLXBhc3N3b3JkCg=="
56 }
57 }
58 available_secrets {
59 secret_manager {
60 env = "MY_SECRET"
61 version_name = "projects/myProject/secrets/mySecret/versions/latest"
62 }
63 }
64 artifacts {
65 images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA"]
66 objects {
67 location = "gs://bucket/path/to/somewhere/"
68 paths = ["path"]
69 }
70 }
71 options {
72 source_provenance_hash = ["MD5"]
73 requested_verify_option = "VERIFIED"
74 machine_type = "N1_HIGHCPU_8"
75 disk_size_gb = 100
76 substitution_option = "ALLOW_LOOSE"
77 dynamic_substitutions = true
78 log_streaming_option = "STREAM_OFF"
79 worker_pool = "pool"
80 logging = "LEGACY"
81 env = ["ekey = evalue"]
82 secret_env = ["secretenv = svalue"]
83 volumes {
84 name = "v1"
85 path = "v1"
86 }
87 }
88 }
89}
90```
View as plain text