Can not set environment variables using other variables?

envars
circle.yml

#1

Can not set env var with this syntax:

build:
  # ...
  environment:
    - MY_CUSTOM_ENV_ONE: ${ENV_VAR_1}-${ENV_VAR_2}
    - MY_CUSTOM_ENV_SECOND: $ENV_VAR_1-$ENV_VAR_2
  # ...

My question, how to create an env var for a build steps using other vars?


#2

Ooh, I didn’t know about the environment key.

What I’d try is:

  • putting env vars inline inside your command e.g.

    command: |
          $USERNAME="${VAR_1}-${VAR_2}" docker login -u $USERNAME ...
    
  • or you could try a separate command at the top that sets them, handy if you have many steps that access the same env var:

    command: |
          export $USERNAME='${VAR_1}-${VAR_2}'
    

That might be available in subsequent run steps - try it?


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.