Using Env Vars in the value of an Env Var

Environment Variables normally contain a single value. However, it is possible to set up an Env Var that includes other Env Vars as values. You can also use values that are normally treated as Env Vars: that is, values including the $ character.

Setting up an embedded Env Var

You can, at any time, use another Environment Variable in the value of an Env Var - embedding the Env Var, so to speak. For example, the value of an Env Var called $BITRISE_IDENTITIES can be a list containing a username, a password, and an API key. The password and the API key would be set as Env Vars:

username: bitrise_user 

You also need to make sure that the key of the Env Var and the keys of any variables it contains are replaced with their values in the input. This whole process is quite simple:

  1. Open your app on
  2. Go to the Workflows tab.
  3. In the Workflow Editor, go to the Env Vars or Secrets tab.
  4. Click Add new.
  5. Add a key and a value.

    The value can contain other Environment Variables.

  6. Toggle the Replace variables in inputs? option.
  7. Click Save.

And that’s it - you can run a build and the variables within your new Env Var will be expanded and you can use their values for whatever you need.

Using the $ sign in an Env Var’s value

It’s very important to note that Bitrise treats everything starting with the $ sign as an Environment Variable. This means that if the value of an Environment Variable contains the $ sign, and the Replace variables in inputs option on the Env Vars or Secrets tab is toggled on, Bitrise will attempt to replace the part beginning with a $ with a value - and of course it will not find any value.

There are two solutions to this issue: