Pipeline: envFrom not working in Task, but it works in step

Created on 27 Oct 2019  路  3Comments  路  Source: tektoncd/pipeline

Expected Behavior

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.

Actual Behavior

The envFrom gets ignore if defined at the Task level, but it works if defined at the step level.

Steps to Reproduce the Problem

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.

Additional Info

Most helpful comment

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.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings