Source a bash file before every command

CircleCI defines an environment variable called BASH_ENV at the start of every build. You can see what this variable is set to at the "Spinning up environment" step.

This can be overridden in the config file or anywhere else that environment variables can be set (e.g. project settings, contexts, etc.).

 If the file exists, it will be sourced with code like the following before every step is executed.

. $BASH_ENV 

This is useful for all sorts of things. If a piece of code generates environment variables used in later steps, adding those variables to the BASH_ENV file is how to get that done, for instance.

This is actually documented, but is easy to miss: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.