# ENV variables fro different branches

**URL:** <https://discuss.circleci.com/t/env-variables-fro-different-branches/3672>\
**Category:** Build Environment\
**Created:** [April 28, 2016, 7:11pm UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672 "2016-04-28T19:11:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![i1skn](https://avatars.discourse-cdn.com/v4/letter/i/c4cdca/32.png) [@i1skn](https://discuss.circleci.com/u/i1skn)\
**Post date:** [April 28, 2016, 7:11pm UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/1 "2016-04-28T19:11:39Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [April 28, 2016, 7:27pm UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/2 "2016-04-28T19:27:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kevart](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevart/32/15580_2.png) [@kevart](https://discuss.circleci.com/u/kevart)\
**Post date:** [March 8, 2017, 5:26pm UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/3 "2017-03-08T17:26:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![martinheidegger](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/martinheidegger/32/15183_2.png) [@martinheidegger](https://discuss.circleci.com/u/martinheidegger)\
**Post date:** [March 21, 2017, 10:52am UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/4 "2017-03-21T10:52:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jamesone](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@jamesone](https://discuss.circleci.com/u/jamesone)\
**Post date:** [April 19, 2017, 11:51pm UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/5 "2017-04-19T23:51:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nitemaeric](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/nitemaeric/32/16542_2.png) [@Nitemaeric](https://discuss.circleci.com/u/Nitemaeric)\
**Post date:** [July 13, 2017, 5:37am UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/6 "2017-07-13T05:37:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/env-variables-fro-different-branches/3672/7 "2018-06-18T11:38:18Z")

</div>


