Passing Environment Variables for Local Builds


Is there a way to pass environment variables for local builds that would otherwise be passed to CircleCI by the UI’s “Environment Variables” setting? Whenever I have to test local builds that require environment variable secrets, I end up hardcoding them temporarily into circle.yml. But I’d rather be able to pass them to the utility. For example by use of a -e/--env flag:

circle-builder build \ 
  -v $(pwd):/opt/app \
  -e AWS_SECRET_ACCESS_KEY=123456789qwerty

or a --env-file flag:

circle-builder build \ 
  -v $(pwd):/opt/app \
  --envfile env.secret

Injecting custom environment variables when running locally via CircleCI CLI

I think there isn’t a way to precisely mimic the UI environment variables at the moment. There is the circleci-builder build --config=file option, so you could have a separate file like a circle.local.yml with all the environment variables. You may want that in .gitignore as well.


Ah, ok. Interesting. Not ideal, but it will work. I’m trying to make this a simple process for devs to build locally via circleci-builder if they want to, but there’s some rough edges like this that make it difficult.


Understood, I can see why this isn’t ideal. I’ll pass it on as UX feedback for the local tool. Thanks!