Source a bash file before every command

Utilizing BASH_ENV

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:


This is useful for all sorts of things. For instance, 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.


Additional resources:

Was this article helpful?
5 out of 9 found this helpful



Article is closed for comments.