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:

. $BASH_ENV 

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: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command

Was this article helpful?
3 out of 6 found this helpful

Comments

0 comments

Please sign in to leave a comment.