Skip to content

Commit 06f4878

Browse files
authored
Merge pull request #87 from tkdchen/add-doc-build-with-args
Add doc: Passing build arguments
2 parents 2b0c565 + a2d8cba commit 06f4878

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

docs/modules/ROOT/pages/how-tos/_nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*** xref:how-tos/configuring/component-nudges.adoc[Defining component relationships]
1010
*** xref:how-tos/configuring/rerunning.adoc[Retriggering build pipelines]
1111
*** xref:how-tos/configuring/redundant-rebuilds.adoc[Preventing redundant rebuilds]
12+
*** xref:how-tos/configuring/build-with-args.adoc[Passing buildah arguments]
1213
** xref:how-tos/testing/index.adoc[Testing your components and applications]
1314
*** xref:how-tos/testing/build/index.adoc[Build-time tests]
1415
**** xref:how-tos/testing/build/snyk.adoc[Enabling Snyk]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
= Passing buildah arguments
2+
3+
{ProductName} buildah task accepts link:https://github.com/konflux-ci/build-definitions/blob/main/task/buildah/0.1/buildah.yaml#L78[`BUILD_ARGS` parameter] that allows passing build arguments to the underlying `buildah` command through `--build-arg` flag. To enable this, make the following changes to the PipelineRuns under the `.tekton/` directory:
4+
5+
. Define a `build-args` Pipeline parameter (if not already present) in `.spec.pipelineSpec.params` to accept the passed-in build arguments.
6+
7+
+
8+
[source,yaml]
9+
--
10+
spec:
11+
# ...
12+
pipelineSpec:
13+
params:
14+
# ...
15+
- name: build-args
16+
type: array
17+
default: []
18+
--
19+
20+
. Pass the argument to link:https://github.com/konflux-ci/build-definitions/tree/main/task/buildah/[buildah task]. Add `BUILD_ARGS` to `build-container.params` (if not already present):
21+
22+
+
23+
[source,yaml]
24+
--
25+
spec:
26+
# ...
27+
pipelineSpec:
28+
tasks:
29+
# ...
30+
- name: build-container
31+
params:
32+
# ...
33+
- name: BUILD_ARGS
34+
value: ["$(params.build-args[*])"]
35+
--
36+
37+
+
38+
The value can also be in form `tasks.<taskName>.results.<resultName>[*]` if it is generated by another task dynamically.
39+
40+
+
41+
For example, you can do more creative things with the `BUILD_ARGS` parameter like this snippet of a pipeline that allows passing `build-args` through the pipeline parameter (as described above) but also incorporates `build-args` generated dynamically by other tasks:
42+
43+
+
44+
[source,yaml]
45+
--
46+
spec:
47+
# ...
48+
pipelineSpec:
49+
tasks:
50+
# ...
51+
- name: build-container
52+
params:
53+
# ...
54+
- name: BUILD_ARGS
55+
value:
56+
# pass the build args array from the pipeline param
57+
- $(params.build-args[*])
58+
# and a dynamically generated array of build args
59+
- $(tasks.my-build-arg-generator-task.results.BUILD_ARGS[*])
60+
# and a build arg with a static name and dynamic value
61+
- VERSION=$(tasks.my-get-version-task.results.VERSION)
62+
--
63+
64+
+
65+
NOTE: Ensure that the value of `BUILD_ARGS` has the correct syntax as described in link:https://tekton.dev/docs/pipelines/variables/[Variable Substitutions Supported by Tasks and Pipelines].
66+
67+
. Pass the desired build arguments in the PipelineRun `.spec.params`:
68+
69+
+
70+
[source,yaml]
71+
--
72+
spec:
73+
params:
74+
# ...
75+
- name: build-args
76+
value: ["ARG1=val", "ARG2=val"] # Add real argument name and value of each build argument
77+
--

0 commit comments

Comments
 (0)