Dynamic App Env

I am using Bitrise cli to test my workflows locally.
I would like to set an app environment variable based on the fact that I am using the cli or the bitrise server


    - SOMEVAR: {{if .IsCI}}some_ci_vaue{{else}}some_local_value{{end}}

Is it possible?

1 Like

Might be possible that way with Go Templates too, but in general the easier solution for this is to set the env var in your .bitrise.secrets.yml and check in your script whether it’s set (if required).


set -ex

if [[ "${SOMEVAR}" == "yes" ]] ; then ...

# OR

if [[ ! -z "${SOMEVAR}" ]] ; then ...

Or, if you have to set it to a specific value, you can use a Script step to set it:

set -ex

if [[ -z "${CI}" ]] ; then
  # not CI env
  envman add --key SOMEVAR --value "some local value"