diff --git a/docs/pipelines.md b/docs/pipelines.md index de9bae82891..3acf19ad8d6 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -149,6 +149,8 @@ For more information, see: ## Specifying `Parameters` +(See also [Specifying Parameters in Tasks](tasks.md#specifying-parameters)) + You can specify global parameters, such as compilation flags or artifact names, that you want to supply to the `Pipeline` at execution time. `Parameters` are passed to the `Pipeline` from its corresponding `PipelineRun` and can replace template values specified within each `Task` in the `Pipeline`. diff --git a/docs/tasks.md b/docs/tasks.md index 1214b60f4f8..aa171137099 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -502,6 +502,23 @@ spec: value: "http://google.com" ``` +Parameter declarations include default values which will be used if the parameter is not specified, for example to +specify defaults for both string params and array params ([full example](../examples/v1beta1/taskruns/array-default.yaml)) : + +```yaml + params: + - name: flags + type: array + - name: flags-default + type: array + default: + - "foo-default" + - "bar-default" + - name: singleVal + type: string + default: "baz" +``` + ### Specifying `Resources` > :warning: **`PipelineResources` are [deprecated](deprecations.md#deprecation-table).** diff --git a/examples/v1beta1/taskruns/array-default.yaml b/examples/v1beta1/taskruns/array-default.yaml new file mode 100644 index 00000000000..10c1931cca3 --- /dev/null +++ b/examples/v1beta1/taskruns/array-default.yaml @@ -0,0 +1,32 @@ +apiVersion: tekton.dev/v1beta1 +kind: TaskRun +metadata: + generateName: array-with-default- +spec: + params: + - name: flags + value: + - "foo" + - "bar" + taskSpec: + params: + - name: flags + type: array + - name: flags-default + type: array + default: + - "foo-default" + - "bar-default" + - name: singleVal + type: string + default: "baz" + steps: + - name: build + image: bash:3.2 + args: [ + "echo", + "$(params.flags[*])", + "$(params.flags-default[*])", + "$(params.singleVal)", + ] +