Reference an environment variable in "environment" yaml map?


#1

Is it possible to use an env var in the “environment” section of our config?

i.e.

environment:
  TEST: ${TEST2}

I’m basically trying to get a env var that is set via web UI to be locally scoped to a specific step.


Environment variables aren't rendering
#2

Not yet but I won’t personally consider 2.0 a full product until that’s implemented :slight_smile:


#3

Hi Billy,

@rohara mentioned workarounds in another post:

In each step, you need to use $(eval echo ${TEST}) instead of ${TEST}. That’s it.


#4

If you’re using bash, you can do something like this:

environment:
    - BASH_ENV: envrc
steps:
    - run:
        echo '
        export TEST=$TEST2
        export PATH=$HOME/bin:$PATH
        ' >> envrc

Any subsequent steps that use bash will automatically source the envrc file.


#5

I just wanted to note we haven’t forgotten about this - it’s still on our roadmap. :slight_smile:


#6

+1 really need this


#7

Just hit this one, any updates?


#8

Huge +1 from me


#9

Can I just triple check I understand the fundamentals of how CircleCI 2.0 should work, and it might help me to understand how and where I can use environment variables.

So, you create a base docker image with all your build dependencies, right? And you define environment variables in your… build step? Are those variables then present within your docker image when you run your build? When you run your build, is the build context completely within that container? Or are you in a VM, which runs your container? Apologies if this is the wrong place to ask, but I’m struggling to get my builds working since upgrading to version 2.0, and it’s mostly down to missing env vars currently!

Any pointers, massive appreciated :slight_smile:

Cheers,

Ewan


#10

Ping, just to make sure is in the priorities for 2018 :slight_smile:


#11

We haven’t forgotten but I definitely wouldn’t hold my breath :frowning:


#12

So 2.0 still isn’t a full product yet?
ducks and runs away…


#13

Cast your vote for this issue in the new “Feature Requests”/Ideas portal


#14

Any update on this? Tried DominickGM’s solution as well but it didn’t work.


#15

Now that we’re being forced to 2.0 in August this year, can we get an update on this?


#16

Yeah, let’s get an update!


#17

+1 here, the workaround isn’t ideal and commands should be able to execute a variable in ${VAR} format like in shell


#18