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
+14
Original file line number
Diff line number
Diff line change
@@ -271,6 +271,20 @@ 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
+
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
279
+
280
+
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.
281
+
282
+
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`.
283
+
284
+
You can also specify `Enum` for `PipelineRun` with an embedded `Pipeline`. The same param validation will be executed in this scenario.
285
+
286
+
See more details in [Param.Enum](./pipelines.md#param-enum).
287
+
274
288
#### Propagated Parameters
275
289
276
290
When using an inlined spec, parameters from the parent `PipelineRun` will be
Copy file name to clipboardexpand all lines: docs/pipelines.md
+64-1
Original file line number
Diff line number
Diff line change
@@ -276,7 +276,70 @@ spec:
276
276
277
277
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
278
278
279
-
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Pipeline`.
279
+
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`:
280
+
281
+
``` yaml
282
+
apiVersion: tekton.dev/v1
283
+
kind: Pipeline
284
+
metadata:
285
+
name: pipeline-param-enum
286
+
spec:
287
+
params:
288
+
- name: message
289
+
enum: ["v1", "v2"]
290
+
default: "v1"
291
+
tasks:
292
+
- name: task1
293
+
params:
294
+
- name: message
295
+
value: $(params.message)
296
+
steps:
297
+
- name: build
298
+
image: bash:3.2
299
+
script: |
300
+
echo "$(params.message)"
301
+
```
302
+
303
+
If the `Param` value passed in by `PipelineRun` is **NOT** in the predefined `enum` list, the `PipelineRun` will fail with reason `InvalidParamValue`.
304
+
305
+
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.
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: ["v2", "v3"]
333
+
tasks:
334
+
- name: task1
335
+
params:
336
+
- name: message
337
+
value: $(params.message)
338
+
taskRef:
339
+
name: param-enum-demo
340
+
```
341
+
342
+
See usage in this [example](../examples/v1/pipelineruns/alpha/param-enum.yaml)
0 commit comments