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: **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.
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` (vis `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` for `PipelineRun` with an embedded `Pipeline`. 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
+63-2
Original file line number
Diff line number
Diff line change
@@ -274,9 +274,70 @@ spec:
274
274
#### Param enum
275
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.
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`, Tekton validates the **intersection** of enum specified in the referenced `Task` and the enum specified in the Pipeline `spec.params`. In the example below, the referenced `Task` accepts `v1` and `v2` as valid values, and the `Pipeline` accepts `v2` and `v3` as valid values. Only passing `v2` in the `PipelineRun` will lead to a sucessful execution.
304
+
305
+
``` yaml
306
+
apiVersion: tekton.dev/v1
307
+
kind: Task
308
+
metadata:
309
+
name: param-enum-demo
310
+
spec:
311
+
params:
312
+
- name: message
313
+
type: string
314
+
enum: ["v1", "v2"]
315
+
steps:
316
+
- name: build
317
+
image: bash:latest
318
+
script: |
319
+
echo "$(params.message)"
320
+
```
321
+
322
+
``` yaml
323
+
apiVersion: tekton.dev/v1
324
+
kind: Pipeline
325
+
metadata:
326
+
name: pipeline-param-enum
327
+
spec:
328
+
params:
329
+
- name: message
330
+
enum: ["v2", "v3"]
331
+
tasks:
332
+
- name: task1
333
+
params:
334
+
- name: message
335
+
value: $(params.message)
336
+
taskRef:
337
+
name: param-enum-demo
338
+
```
339
+
340
+
See usage in this [example](../examples/v1/pipelineruns/alpha/param-enum.yaml)
Copy file name to clipboardexpand all lines: docs/taskruns.md
-2
Original file line number
Diff line number
Diff line change
@@ -406,8 +406,6 @@ go through the complexity of checking each `Task` and providing only the require
406
406
407
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
408
409
-
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
410
-
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.
412
410
413
411
You can also specify `Enum` for [`TaskRun` with an embedded `Task`](#example-taskrun-with-an-embedded-task). The same param validation will be executed in this scenario.
Copy file name to clipboardexpand all lines: docs/tasks.md
-2
Original file line number
Diff line number
Diff line change
@@ -715,8 +715,6 @@ spec:
715
715
#### Param enum
716
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
717
718
-
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
719
-
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