You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/pipelineruns.md
+12
Original file line number
Diff line number
Diff line change
@@ -271,6 +271,18 @@ case is when your CI system autogenerates `PipelineRuns` and it has `Parameters`
271
271
provide to all `PipelineRuns`. Because you can pass in extra `Parameters`, you don't have to
272
272
go through the complexity of checking each `Pipeline` and providing only the required params.
273
273
274
+
#### Parameter Enums
275
+
276
+
> :seedling: **`enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
277
+
278
+
If a `Parameter` is guarded by `Enum` in the `Pipeline`, you can only provide `Parameter` values in the `PipelineRun` that are predefined in the `Param.Enum` in the `Pipeline`. The `PipelineRun` will fail with reason `InvalidParamValue` otherwise.
279
+
280
+
Tekton will also the validate the `param` values passed to any referenced `Tasks` (via `taskRef`) if `Enum` is specified for the `Task`. The `PipelineRun` will fail with reason `InvalidParamValue` if `Enum` validation is failed for any of the `PipelineTask`.
281
+
282
+
You can also specify `Enum` in an embedded `Pipeline` in a `PipelineRun`. The same `Param` validation will be executed in this scenario.
283
+
284
+
See more details in [Param.Enum](./pipelines.md#param-enum).
285
+
274
286
#### Propagated Parameters
275
287
276
288
When using an inlined spec, parameters from the parent `PipelineRun` will be
Copy file name to clipboardexpand all lines: docs/pipelines.md
+69-3
Original file line number
Diff line number
Diff line change
@@ -272,11 +272,77 @@ spec:
272
272
```
273
273
274
274
#### Param enum
275
-
> :seedling: **Specifying `enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
275
+
> :seedling: **`enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
276
276
277
-
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
277
+
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Pipeline` `Param`. For example, the valid/allowed values for `Param` "message" is bounded to `v1` and `v2`:
278
278
279
-
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Pipeline`.
279
+
``` yaml
280
+
apiVersion: tekton.dev/v1
281
+
kind: Pipeline
282
+
metadata:
283
+
name: pipeline-param-enum
284
+
spec:
285
+
params:
286
+
- name: message
287
+
enum: ["v1", "v2"]
288
+
default: "v1"
289
+
tasks:
290
+
- name: task1
291
+
params:
292
+
- name: message
293
+
value: $(params.message)
294
+
steps:
295
+
- name: build
296
+
image: bash:3.2
297
+
script: |
298
+
echo "$(params.message)"
299
+
```
300
+
301
+
If the `Param` value passed in by `PipelineRun` is **NOT** in the predefined `enum` list, the `PipelineRun` will fail with reason `InvalidParamValue`.
302
+
303
+
If a `PipelineTask` references a `Task` with `enum`, the `enums` specified in the Pipeline `spec.params` (pipeline-level `enum`) must be
304
+
a **subset** of the `enums` specified in the referenced `Task` (task-level `enum`). Note that an empty pipeline-level `enum` is invalid
305
+
in this scenario since an empty `enum` set indicates a "universal set" which allows all possible values. In the below example, the referenced `Task` accepts `v1` and `v2` as valid values, the `Pipeline` further restricts the valid values to `v1`.
306
+
307
+
``` yaml
308
+
apiVersion: tekton.dev/v1
309
+
kind: Task
310
+
metadata:
311
+
name: param-enum-demo
312
+
spec:
313
+
params:
314
+
- name: message
315
+
type: string
316
+
enum: ["v1", "v2"]
317
+
steps:
318
+
- name: build
319
+
image: bash:latest
320
+
script: |
321
+
echo "$(params.message)"
322
+
```
323
+
324
+
``` yaml
325
+
apiVersion: tekton.dev/v1
326
+
kind: Pipeline
327
+
metadata:
328
+
name: pipeline-param-enum
329
+
spec:
330
+
params:
331
+
- name: message
332
+
enum: ["v1"] # note that an empty enum set is invalid
333
+
tasks:
334
+
- name: task1
335
+
params:
336
+
- name: message
337
+
value: $(params.message)
338
+
taskRef:
339
+
name: param-enum-demo
340
+
```
341
+
342
+
Tekton validates user-provided values in a `PipelineRun` against the `enum` specified in the `PipelineSpec.params`. Tekton also validates
343
+
any resolved `param` value against the `enum` specified in each `PipelineTask` before creating the `TaskRun`.
344
+
345
+
See usage in this [example](../examples/v1/pipelineruns/alpha/param-enum.yaml)
Copy file name to clipboardexpand all lines: docs/taskruns.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -404,9 +404,7 @@ go through the complexity of checking each `Task` and providing only the require
404
404
405
405
#### Parameter Enums
406
406
407
-
> :seedling: **Specifying `enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
408
-
409
-
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
407
+
> :seedling: **`enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
410
408
411
409
If a `Parameter` is guarded by `Enum` in the `Task`, you can only provide `Parameter` values in the `TaskRun` that are predefined in the `Param.Enum` in the `Task`. The `TaskRun` will fail with reason `InvalidParamValue` otherwise.
Copy file name to clipboardexpand all lines: docs/tasks.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -713,9 +713,7 @@ spec:
713
713
```
714
714
715
715
#### Param enum
716
-
> :seedling: **Specifying `enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
717
-
718
-
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
716
+
> :seedling: **`enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature.
719
717
720
718
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Param`. For example, the valid/allowed values for `Param` "message" is bounded to `v1`, `v2` and `v3`:
0 commit comments