Support environment variable substitution in environment blocks/maps

envars
circle.yml
cci-20

#1

I have the need to configure multiple AWS credentials in different steps of my builds.
I was planning to use the environment block of the run step to inject those variables.
However, it seems that the environment block does not support variable substitution and simply takes the string verbatim.

This is what I would like to do:

    - run:
      environment:
        AWS_ACCESS_KEY_ID: ${DEV_AWS_ACCESS_KEY_ID}
        AWS_SECRET_ACCESS_KEY: ${DEV_AWS_SECRET_ACCESS_KEY}
      command: do-something.sh

However I end up having to do this instead:

    - run:
      command: AWS_ACCESS_KEY_ID=${DEV_AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${DEV_AWS_SECRET_ACCESS_KEY} do-something.sh

Although the workaround is viable, the command string will only get longer and longer as other things might be needed. This will negatively affect the readability of the statement and as a consequence also its maintainability.


#2

There are a better workarounds with a multi-line run step:

    command: |
      AWS_ACCESS_KEY_ID=${DEV_AWS_ACCESS_KEY_ID} \
      AWS_SECRET_ACCESS_KEY=${DEV_AWS_SECRET_ACCESS_KEY} \
      do-something.sh

or

    command: |
      export AWS_ACCESS_KEY_ID=${DEV_AWS_ACCESS_KEY_ID}
      export AWS_SECRET_ACCESS_KEY=${DEV_AWS_SECRET_ACCESS_KEY}

      do-something.sh

Still not ideal though!


#3