Skip to content

Commit b110213

Browse files
mathyourlife-fitbitnat-henderson
authored andcommitted
Add new google_cloudbuild_trigger resource (hashicorp#1357)
1 parent 94025e4 commit b110213

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

Diff for: docs/r/cloudbuild_trigger.html.markdown

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
layout: "google"
3+
page_title: "Google: google_cloudbuild_trigger"
4+
sidebar_current: "docs-google-cloudbuild-trigger"
5+
description: |-
6+
Creates a new build trigger within GCR.
7+
---
8+
9+
# google\_cloudbuild\_trigger
10+
11+
Creates a new build trigger within GCR. For more information, see
12+
[the official documentation](https://cloud.google.com/container-builder/docs/running-builds/automate-builds)
13+
and
14+
[API](https://godoc.org/google.golang.org/api/cloudbuild/v1#BuildTrigger).
15+
16+
## Example Usage
17+
18+
```hcl
19+
resource "google_cloudbuild_trigger" "build_trigger" {
20+
project = "my-project"
21+
trigger_template {
22+
branch_name = "master"
23+
project = "my-project"
24+
repo_name = "some-repo"
25+
}
26+
build {
27+
images = ["gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA"]
28+
step {
29+
name = "gcr.io/cloud-builders/docker"
30+
args = "build -t gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA -f Dockerfile ."
31+
}
32+
}
33+
}
34+
```
35+
36+
## Argument Reference
37+
38+
(Argument descriptions sourced from https://godoc.org/google.golang.org/api/cloudbuild/v1#BuildTrigger)
39+
40+
The following arguments are supported:
41+
42+
* `description` - (Optional) A brief description of this resource.
43+
44+
* `trigger_template` - (Optional) Location of the source in a Google
45+
Cloud Source Repository. Structure is documented below.
46+
47+
* `build` - (Optional) A build resource in the Container Builder API.
48+
Structure is documented below. At a high
49+
level, a `build` describes where to find source code, how to build it (for
50+
example, the builder image to run on the source), and where to store
51+
the built artifacts. Fields can include the following variables, which
52+
will be expanded when the build is created:
53+
* `$PROJECT_ID`: the project ID of the build.
54+
* `$BUILD_ID`: the autogenerated ID of the build.
55+
* `$REPO_NAME`: the source repository name specified by RepoSource.
56+
* `$BRANCH_NAME`: the branch name specified by RepoSource.
57+
* `$TAG_NAME`: the tag name specified by RepoSource.
58+
* `$REVISION_ID` or `$COMMIT_SHA`: the commit SHA specified by RepoSource
59+
or resolved from the specified branch or tag.
60+
* `$SHORT_SHA`: first 7 characters of `$REVISION_ID` or `$COMMIT_SHA`.
61+
62+
---
63+
64+
The `trigger_template` block supports:
65+
66+
* `branch_name` - (Optional) Name of the branch to build.
67+
68+
* `commit_sha` - (Optional) Explicit commit SHA to build.
69+
70+
* `dir` - (Optional) Directory, relative to the source root, in which to run
71+
the build. This must be a relative path. If a step's `dir` is specified and
72+
is an absolute path, this value is ignored for that step's execution.
73+
74+
* `project` - (Optional) ID of the project that owns the Cloud Source Repository.
75+
76+
* `repo_name` - (Optional) Name of the Cloud Source Repository.
77+
78+
* `tag_name` - (Optional) Name of the tag to build.
79+
80+
81+
---
82+
83+
The `build` block supports:
84+
85+
* `images` - (Optional) A list of images to be pushed upon the successful
86+
completion of all build steps.
87+
88+
* `step` - (Optional) The operations to be performed on the workspace.
89+
Structure is documented below.
90+
91+
* `tags` - (Optional) Tags for annotation of a build. **These are not docker tags**
92+
93+
---
94+
95+
The `step` block supports:
96+
97+
* `name` - (Optional) The name of the container image that will run this
98+
particular build step. If the image is available in the host's Docker
99+
daemon's cache, it will be run directly. If not, the host will attempt to
100+
pull the image first, using the builder service account's credentials if
101+
necessary. The Docker daemon's cache will already have the latest versions
102+
of all of the officially supported build steps
103+
(https://github.com/GoogleCloudPlatform/cloud-builders).
104+
The Docker daemon will also have cached many of the layers for some popular
105+
images, like "ubuntu", "debian", but they will be refreshed at the time you
106+
attempt to use them. If you built an image in a previous build step, it will
107+
be stored in the host's Docker daemon's cache and is available to use as
108+
the name for a later build step.
109+
110+
* `args` - (Optional) A list of arguments that will be presented to the step
111+
when it is started. If the image used to run the step's container has an
112+
entrypoint, the `args` are used as arguments to that entrypoint. If the image
113+
does not define an entrypoint, the first element in args is used as the
114+
entrypoint, and the remainder will be used as arguments.

Diff for: google.erb

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@
129129
</ul>
130130
</li>
131131

132+
<li<%= sidebar_current("docs-google-cloudbuild") %>>
133+
<a href="#">Google Cloud Build Resources</a>
134+
<ul class="nav nav-visible">
135+
<li<%= sidebar_current("docs-google-cloudbuild-trigger") %>>
136+
<a href="/docs/providers/google/r/cloudbuild_trigger.html">google_cloudbuild_trigger</a>
137+
</li>
138+
</ul>
139+
</li>
140+
132141
<li<%= sidebar_current("docs-google-cloudfunctions") %>>
133142
<a href="#">Google Cloud Functions Resources</a>
134143
<ul class="nav nav-visible">

0 commit comments

Comments
 (0)