ENV variables fro different branches

Hello, Circle CI Community!

I have a question.
I’m using docker cloud for my solutions. So I’m building image on Circle CI side and after push it to docker hub.
For every environment (like production, staging etc) I’m using different database credentials.
I do not want to add this credentials into github repo, so I want ask is there any way to store like ENVIRONMENT variables, but per each env (like production, staging etc).

Thnx, so much!

2 Likes

Hi,

You don’t have separate envars for each branch as you mentioned however you can easily work around that. For example, for a DB password you can have envars like DB_PASSWD_PROD and DB_PASSWD_STAGE for each environment.

Then you can use the standard envar CIRCLE_BRANCH in a script or circle.yml to determine which password to use. CIRCLE_BRANCH holds the name of the Git branch currently being built in CircleCI.

It’s been nearly a year since the last reply is there an update on this? ENV variables get a bit messy when having lots and most of them twice.

Not every one in our organization can commit/push to the master branch. So by having environment variables available on the master branch only we can make sure that no branch-deployment has access to master credentials. The feature (available in travis-ci) is important for a secure deployment system.

Hey! Is this any update on whether you’ll be adding per branch ENVS? Is there some sort of architectural problem with adding this functionality? It would be a huge addition as most deployed environments use 1 set of environment variables

Hi, I’d also like to tag along for this thread. I’m currently using CircleCI to do deployments for my frontend website. The process requires us to compile our React app on the build machine and then deploy to different servers with different configurations.