Skip to content

Commit

Permalink
Add params section to Pipelinerun doc
Browse files Browse the repository at this point in the history
Adds params section to Pipelinerun doc to explain
how to specify params in a Pipelinerun Spec

Add examples in `examples/v1alpha1/pipelineruns` and `examples/v1beta1/pipelineruns`

Fixes #2153

Signed-off-by: Nikhil Thomas <nikthoma@redhat.com>
  • Loading branch information
nikhil-thomas authored and tekton-robot committed Mar 6, 2020
1 parent f1e3801 commit 8f427a8
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/pipelineruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ Creation of a `PipelineRun` will trigger the creation of

- [Syntax](#syntax)
- [Resources](#resources)
- [Params](#params)
- [Service account](#service-account)
- [Service accounts](#service-accounts)
- [Pod Template](#pod-template)
- [Workspaces](#workspaces)
- [Cancelling a PipelineRun](#cancelling-a-pipelinerun)
- [Examples](https://github.com/tektoncd/pipeline/tree/master/examples/pipelineruns)
- [Examples](https://github.com/tektoncd/pipeline/tree/master/examples/v1beta1/pipelineruns)
- [Logs](logs.md)
- [LimitRanges](#limitranges)

Expand All @@ -39,6 +40,7 @@ following fields:
- Optional:
- [`resources`](#resources) - Specifies which
[`PipelineResources`](resources.md) to use for this `PipelineRun`.
- [`params`](#params) - Specifies which params to be passed to the pipeline specified/referenced by this pipeline run.
- [`serviceAccountName`](#service-account) - Specifies a `ServiceAccount` resource
object that enables your build to run with the defined authentication
information. When a `ServiceAccount` isn't specified, the `default-service-account`
Expand Down Expand Up @@ -171,6 +173,23 @@ spec:
value: gcr.io/christiewilson-catfactory/leeroy-app
```

### Params

While writing a Pipelinerun, we can specify params that need to be bound to
the input params of the pipeline specified/referenced by the Pipelinerun.

This means that a Pipeline can be run with different input params, by writing Pipelineruns
which bound different input values to the Pipeline params.

```yaml
spec:
params:
- name: pl-param-x
value: "100"
- name: pl-param-y
value: "500"
```

### Service Account

Specifies the `name` of a `ServiceAccount` resource object. Use the
Expand Down
92 changes: 92 additions & 0 deletions examples/v1alpha1/pipelineruns/pipelinerun-with-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: pipeline-with-params
spec:
params:
- name: pl-param-x
type: string
default: "1"
- name: pl-param-y
type: string
default: "1"
tasks:
- name: sum-params
taskRef:
name: sum-params
params:
- name: a
value: "$(params.pl-param-x)"
- name: b
value: "$(params.pl-param-y)"
- name: multiply-params
taskRef:
name: multiply-params
params:
- name: a
value: "$(params.pl-param-x)"
- name: b
value: "$(params.pl-param-y)"
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: sum-params
annotations:
description: |
A simple task that sums the two provided integers
spec:
inputs:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
steps:
- name: sum
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n $(( "$(inputs.params.a)" + "$(inputs.params.b)" ))
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: multiply-params
annotations:
description: |
A simple task that multiplies the two provided integers
spec:
inputs:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
steps:
- name: product
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n $(( "$(inputs.params.a)" * "$(inputs.params.b)" ))
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: pipelinerun-with-params
spec:
params:
- name: pl-param-x
value: "100"
- name: pl-param-y
value: "500"
pipelineRef:
name: pipeline-with-params
90 changes: 90 additions & 0 deletions examples/v1beta1/pipelineruns/pipelinerun-with-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: pipeline-with-params
spec:
params:
- name: pl-param-x
type: string
default: "1"
- name: pl-param-y
type: string
default: "1"
tasks:
- name: sum-params
taskRef:
name: sum-params
params:
- name: a
value: "$(params.pl-param-x)"
- name: b
value: "$(params.pl-param-y)"
- name: multiply-params
taskRef:
name: multiply-params
params:
- name: a
value: "$(params.pl-param-x)"
- name: b
value: "$(params.pl-param-y)"
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sum-params
annotations:
description: |
A simple task that sums the two provided integers
spec:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
steps:
- name: sum
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n $(( "$(inputs.params.a)" + "$(inputs.params.b)" ))
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: multiply-params
annotations:
description: |
A simple task that multiplies the two provided integers
spec:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
steps:
- name: product
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n $(( "$(inputs.params.a)" * "$(inputs.params.b)" ))
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: pipelinerun-with-params
spec:
params:
- name: pl-param-x
value: "100"
- name: pl-param-y
value: "500"
pipelineRef:
name: pipeline-with-params

0 comments on commit 8f427a8

Please sign in to comment.