Skip to content

Commit

Permalink
Add example that uses stepTemplate 🐾
Browse files Browse the repository at this point in the history
There weren't any "yaml tests" aka examples that used the stepTemplate
so after I renamed `stepTemplate` from `containerTemplate` it was not
100% clear if this worked. Also it's helpful to provide examples to
users to see it in action :)
  • Loading branch information
bobcatfish committed Jun 11, 2019
1 parent cff8c8e commit 53db5c9
Showing 1 changed file with 51 additions and 42 deletions.
93 changes: 51 additions & 42 deletions examples/taskruns/task-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,56 @@ kind: Task
metadata:
name: task-env-merge
spec:
# This template will be applied to all steps
stepTemplate:
env:
- name: QUX
value: original
inputs:
params:
- name: FOO
description: FOO variable
- name: BAR
description: BAR variable
- name: FOOBAR
description: FOODBAR variable
default: foobar
- name: FOO
description: FOO variable
- name: BAR
description: BAR variable
- name: FOOBAR
description: FOODBAR variable
default: foobar
steps:
# Test the environment variables are set in the task
# using this template
- name: foo
image: ubuntu
command: ['bash']
args: ['-c', '[[ ${FOO} == "foo" ]]']
env:
- name: FOO
value: ${inputs.params.FOO}
- name: foobar
image: ubuntu
command: ['bash']
args: ['-c', '[[ ${FOOBAR} == "foobar" ]]']
env:
- name: FOOBAR
value: ${inputs.params.FOOBAR}
- name: bar
image: ubuntu
command: ['bash']
args: ['-c', '[[ ${BAR} == "bar" ]]']
env:
- name: BAR
value: ${inputs.params.BAR}
# Use the taskrun's declared env value, overriding the template's
- name: foo-override
image: ubuntu
command: ['bash']
args: ['-c', '[[ ${FOO} == "bazzzzz" ]]']
env:
- name: FOO
value: bazzzzz
# Test the environment variables are set in the task
- name: foo
image: ubuntu
command: ["bash"]
args: ["-c", '[[ ${FOO} == "foo" ]]']
env:
- name: FOO
value: ${inputs.params.FOO}
- name: foobar
image: ubuntu
command: ["bash"]
args: ["-c", '[[ ${FOOBAR} == "foobar" ]]']
env:
- name: FOOBAR
value: ${inputs.params.FOOBAR}
- name: bar
image: ubuntu
command: ["bash"]
args: ["-c", '[[ ${BAR} == "bar" ]]']
env:
- name: BAR
value: ${inputs.params.BAR}
# Use the env var from the stepTemplate
- name: qux-no-override
image: ubuntu
command: ["bash"]
args: ["-c", '[[ ${QUX} == "original" ]]']
# Override the env var in the stepTemplate
- name: qux-override
image: ubuntu
command: ["bash"]
args: ["-c", '[[ ${QUX} == "override" ]]']
env:
- name: QUX
value: override
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
Expand All @@ -53,9 +62,9 @@ metadata:
spec:
inputs:
params:
- name: FOO
value: foo
- name: BAR
value: bar
- name: FOO
value: foo
- name: BAR
value: bar
taskRef:
name: task-env-merge

0 comments on commit 53db5c9

Please sign in to comment.