For envFrom to work when defined in Task resource for configMap or Secrets.
I would like to define a group of environment variables that are required by multiple steps within the same task.
The envFrom gets ignore if defined at the Task level, but it works if defined at the step level.
Define task that uses envFrom using a configMap for example.
The configMap pactbroker-config contains the key, value PACTBROKER_URL=http://example.com
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: node-react-task-tmp
spec:
envFrom:
- configMapRef:
name: pactbroker-config
steps:
- name: test1
image: ubuntu
command: ["/bin/bash"]
args:
- -c
- |
echo "PACTBROKER_URL=${PACTBROKER_URL}"
- name: test2
image: ubuntu
command: ["/bin/bash"]
args:
- -c
- |
echo "PACTBROKER_URL=${PACTBROKER_URL}"
run a task via a pipeline.
Hey @csantanapr envFrom comes from the container spec which is roughly what a Step is based on but there is no similar concept for a Task/Pod. What you can do is in your Task use a https://github.com/tektoncd/pipeline/blob/master/docs/tasks.md#step-template to define an envFrom that will be reflected in each step.
ah cool, yes stepTemplate will save me from the duplicates on each step
closing since stepTemplate solves this
Most helpful comment
Hey @csantanapr
envFromcomes from the container spec which is roughly what a Step is based on but there is no similar concept for a Task/Pod. What you can do is in your Task use a https://github.com/tektoncd/pipeline/blob/master/docs/tasks.md#step-template to define anenvFromthat will be reflected in each step.