Sourcing bash file before every "run" command?



Hi, I was wondering if it’s possible to source a file before each of my - run: commands? It doesn’t appear to source either .bashrc or .profile. I’m using nvm in my main image and right now, I’d have to do something like this, which is a bit annoying:

- run: ". ~/.nvm/; nvm use 7"
- run: ". ~/.nvm/; npm install"


Sourcing bashrc before run on machine executor

Yes, you can! Define BASH_ENV: ~/.bashrc as an environment variable and it will automatically source ~/.bashrc for you on each run.

  BASH_ENV: "~/.nvm/"


Thanks! I ended up with:

  BASH_ENV: ".circleci/"

And .circleci/

# for local builds using "circleci build"
# will be ignored on circleci since is gitignored
[ -f "${circleci_env_file}" ] && source "${circleci_env_file}"

# nvm
source ~/.nvm/


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.