Looks like a script step doing export SOMEVAR=1
does not set SOMEVAR
environment variable for other steps.
If you do an export
that will only export that env var for that specific Step. Subsequent steps are not affected, the environment variable won’t be set in them.
If you want to set an env var for the whole config please use App Env Vars (on the Env Vars tab of the editor). You can also set workflow specific env vars there on that tab. If you’d really need to expose from a step, please follow this guide: http://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/
Technical explanation: every Step runs in a new (OS) process, and when a (OS) process ends the env vars it sets via export
or any other method are lost. A new process (not started by that process) is never affected by another process’ environment variables.
A short example:
- Create two bash scripts, one which sets the env var (
export SOMEVAR=1
- save it intoset_env_var.sh
) and another one which prints the env var’s value (echo "$SOMEVAR"
- save it intoprint_env_var.sh
) - Run the first script (e.g.
bash set_env_var.sh
) - Run the second script (e.g.
bash print_env_var.sh
)
The second script will not print the value of the env var, as it does not have access to it. When the execution of bash set_env_var.sh
ends the env vars it did set are also removed.
If you’d run bash print_env_var.sh
from the set_env_var.sh
script then that could print the value, as in that case the print..
script is started by the first process - it becomes a child process of the process which starts it. But as mentioned above, Bitrise CLI runs every Step in a new, separate OS process, so a simple export
is not enough to expose an env var between steps.