Skip to content

Commit efc3bd0

Browse files
authored
Merge pull request #14747 from justaugustus/img-build
images/builder: Allow GCB builds from arbitrary build directories
2 parents 85cef90 + a932f17 commit efc3bd0

File tree

3 files changed

+131
-50
lines changed

3 files changed

+131
-50
lines changed

config/jobs/kubernetes/test-infra/test-infra-trusted.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ postsubmits:
4747
args:
4848
- --scratch-bucket=gs://k8s-testimages-scratch
4949
- --project=k8s-testimages
50+
- --build-dir=.
5051
- images/alpine-bash/
5152
env:
5253
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -75,6 +76,7 @@ postsubmits:
7576
args:
7677
- --scratch-bucket=gs://k8s-testimages-scratch
7778
- --project=k8s-testimages
79+
- --build-dir=.
7880
- images/boskosctl-base/
7981
env:
8082
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -161,6 +163,7 @@ postsubmits:
161163
args:
162164
- --scratch-bucket=gs://k8s-testimages-scratch
163165
- --project=k8s-testimages
166+
- --build-dir=.
164167
- velodrome/
165168
env:
166169
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -219,6 +222,7 @@ postsubmits:
219222
args:
220223
- --scratch-bucket=gs://k8s-testimages-scratch
221224
- --project=k8s-testimages
225+
- --build-dir=.
222226
- kettle/
223227
env:
224228
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -250,6 +254,7 @@ postsubmits:
250254
args:
251255
- --scratch-bucket=gs://k8s-testimages-scratch
252256
- --project=k8s-testimages
257+
- --build-dir=.
253258
- planter/
254259
env:
255260
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -281,6 +286,7 @@ postsubmits:
281286
args:
282287
- --scratch-bucket=gs://k8s-testimages-scratch
283288
- --project=k8s-testimages
289+
- --build-dir=.
284290
- triage/
285291
env:
286292
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -312,6 +318,7 @@ postsubmits:
312318
args:
313319
- --scratch-bucket=gs://k8s-testimages-scratch
314320
- --project=k8s-testimages
321+
- --build-dir=.
315322
- images/bazelbuild/
316323
env:
317324
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -343,6 +350,7 @@ postsubmits:
343350
args:
344351
- --scratch-bucket=gs://k8s-testimages-scratch
345352
- --project=k8s-testimages
353+
- --build-dir=.
346354
- images/bazel-krte/
347355
env:
348356
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -374,6 +382,7 @@ postsubmits:
374382
args:
375383
- --scratch-bucket=gs://k8s-testimages-scratch
376384
- --project=k8s-testimages
385+
- --build-dir=.
377386
- images/bigquery/
378387
env:
379388
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -405,6 +414,7 @@ postsubmits:
405414
args:
406415
- --scratch-bucket=gs://k8s-testimages-scratch
407416
- --project=k8s-testimages
417+
- --build-dir=.
408418
- images/bootstrap/
409419
env:
410420
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -436,6 +446,7 @@ postsubmits:
436446
args:
437447
- --scratch-bucket=gs://k8s-testimages-scratch
438448
- --project=k8s-testimages
449+
- --build-dir=.
439450
- images/cluster-api/
440451
env:
441452
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -467,6 +478,7 @@ postsubmits:
467478
args:
468479
- --scratch-bucket=gs://k8s-testimages-scratch
469480
- --project=k8s-testimages
481+
- --build-dir=.
470482
- images/gcb-docker-gcloud/
471483
env:
472484
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -498,6 +510,7 @@ postsubmits:
498510
args:
499511
- --scratch-bucket=gs://k8s-testimages-scratch
500512
- --project=k8s-testimages
513+
- --build-dir=.
501514
- images/gcloud/
502515
env:
503516
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -529,6 +542,7 @@ postsubmits:
529542
args:
530543
- --scratch-bucket=gs://k8s-testimages-scratch
531544
- --project=k8s-testimages
545+
- --build-dir=.
532546
- images/kubekins-e2e/
533547
env:
534548
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -591,6 +605,7 @@ postsubmits:
591605
args:
592606
- --scratch-bucket=gs://k8s-testimages-scratch
593607
- --project=k8s-testimages
608+
- --build-dir=.
594609
- images/kubekins-test/
595610
env:
596611
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -622,6 +637,7 @@ postsubmits:
622637
args:
623638
- --scratch-bucket=gs://k8s-testimages-scratch
624639
- --project=k8s-testimages
640+
- --build-dir=.
625641
- images/kubemci/
626642
env:
627643
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -653,6 +669,7 @@ postsubmits:
653669
args:
654670
- --scratch-bucket=gs://k8s-testimages-scratch
655671
- --project=k8s-testimages
672+
- --build-dir=.
656673
- images/pull-test-infra-gubernator/
657674
env:
658675
- name: GOOGLE_APPLICATION_CREDENTIALS
@@ -684,6 +701,7 @@ postsubmits:
684701
args:
685702
- --scratch-bucket=gs://k8s-testimages-scratch
686703
- --project=k8s-testimages
704+
- --build-dir=.
687705
- images/builder/
688706
env:
689707
- name: GOOGLE_APPLICATION_CREDENTIALS

images/builder/README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
Image Builder
2-
=============
1+
# GCB Builder
32

4-
This image builder is sugar on top of `gcloud builds submit`. It offers the following features:
3+
This builder is sugar on top of `gcloud builds submit`. It offers the following features:
54

65
- Automatically injecting the standard commit-based tag (e.g. `20190403-dddd315ad-dirty`) as `_GIT_TAG`
76
- Optionally blocking pushes of dirty builds
@@ -14,36 +13,38 @@ and `cloudbuild.yaml`. For example, a subset of the `kubekins-e2e` variants look
1413

1514
```yaml
1615
variants:
17-
'1.14':
18-
CONFIG: '1.14'
19-
GO_VERSION: 1.12.1
20-
K8S_RELEASE: latest
21-
BAZEL_VERSION: 0.21.0
22-
'1.13':
23-
CONFIG: '1.13'
24-
GO_VERSION: 1.11.5
25-
K8S_RELEASE: stable-1.13
26-
BAZEL_VERSION: 0.18.1
16+
'1.16':
17+
CONFIG: '1.16'
18+
GO_VERSION: 1.12.12
19+
K8S_RELEASE: stable-1.16
20+
BAZEL_VERSION: 0.23.2
21+
'1.15':
22+
CONFIG: '1.15'
23+
GO_VERSION: 1.12.12
24+
K8S_RELEASE: stable-1.15
25+
BAZEL_VERSION: 0.23.2
2726
```
2827
29-
By default, the image builder will build both the `1.13` and `1.14` groups simultaneously.
30-
If `--log-dir` is specified, it will write the build logs for each to `1.13.log` and `1.14.log`.
28+
By default, the image builder will build both the `1.15` and `1.16` groups simultaneously.
29+
If `--log-dir` is specified, it will write the build logs for each to `1.15.log` and `1.16.log`.
3130

32-
Alternatively, you can use `--variant` to build only one variant, e.g. `--variant 1.13`.
31+
Alternatively, you can use `--variant` to build only one variant, e.g. `--variant 1.15`.
3332

3433
If no `variants.yaml` is specified, `cloudbuild.yaml` will be run once with no extra substitutions
3534
beyond `_GIT_TAG`.
3635

3736
## Usage
3837

39-
```
40-
bazel run //images/builder -- [options] path/to/image-directory/
38+
```shell
39+
bazel run //images/builder -- [options] path/to/build-directory/
4140
```
4241

43-
* `--allow-dirty`: If true, allow pushing dirty builds.
44-
* `--log-dir`: If provided, build logs will be sent to files in this directory instead of to stdout/stderr.
45-
* `--project`: If specified, use a non-default GCP project.
46-
* `--scratch-bucket`: If provided, the complete GCS path for Cloud Build to store scratch files (sources, logs). Necessary for upload reuse. If omitted, `gcloud` will create or reuse a bucket of its choosing.
47-
* `--variant`: If specified, build only the given variant. An error if no variants are defined.
48-
* `--env-passthrough`: A comma-separated list of environment variables to pass through as substitutions.
49-
The substitution names will automatically be prefixed with underscores, as required by GCB.
42+
- `--allow-dirty`: If true, allow pushing dirty builds.
43+
- `--log-dir`: If provided, build logs will be sent to files in this directory instead of to stdout/stderr.
44+
- `--project`: If specified, use a non-default GCP project.
45+
- `--scratch-bucket`: If provided, the complete GCS path for Cloud Build to store scratch files (sources, logs). Necessary for upload reuse. If omitted, `gcloud` will create or reuse a bucket of its choosing.
46+
- `--variant`: If specified, build only the given variant. An error if no variants are defined.
47+
- `--env-passthrough`: Comma-separated list of specified environment variables to be passed to GCB as substitutions with an underscore (`_`) prefix. If the variable doesn't exist, the substitution will exist but be empty.
48+
- `--build-dir`: If provided, this directory will be uploaded as the source for the Google Cloud Build run.
49+
- `--gcb-config`: If provided, this will be used as the name of the Google Cloud Build config file.
50+
- `--no-source`: If true, no source will be uploaded with this build.

0 commit comments

Comments
 (0)