Answers: <p>I'm not familiar with teamcity, but you can :</p>
  
  <ul>
  <li>add a config folder in your repo, and inside this repo</li>
  <li>create three files (staging.yml, preprod.yml, prod.yml). </li>
  <li>on each file you will write down variables specific to each
  environment, and apply them within pipeline.</li>
  </ul>
  
  <p>For secrets, it's cautious to handle that manually or better use Vault.</p>
  
  <p>To not throw on error your pipeline/pods, set secrets as optional that could help if you want to set them later. </p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-20T20:25:38.697Z
Answers: obviously I do not want to add my secrets in the repository :)
Answers: Cyclonecode
Answers: CC BY-SA 4.0
Answers: 2019-07-21T14:49:43.803Z
Answers: The problem is that I need to create a build which then can be deployed to different environments such as test, stage and production using different secrets such as api keys, passwords and more. The important thing here is that some settings also needs to be added to the environment in the actual build step.
Answers: Cyclonecode
Answers: CC BY-SA 4.0
Answers: 2019-07-20T20:21:17.290Z
Answers: 2019-07-20T20:21:17.290Z
Answers: zidosni
Answers: <p>If you are using kubernetes as deployment environment,  you could use configmaps and apply them on building your code.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-21T23:08:52.527Z
Answers: As you can see in my question I am using teamcity =)
Answers: Cyclonecode
Answers: CC BY-SA 4.0
Answers: 2019-07-21T21:23:53.440Z
Answers: 2019-07-21T21:23:53.440Z
Answers: zidosni
Body: <p>I am using teamcity to automatically build and test a nodejs application. The problem I am facing is that the application needs to have some environment variables set during the build phase, as well as some secret variables that need to be set during the actual deployment (this is a manual step). These environment variables should be different depending on where the application should be deployed and I have no idea on how to solve this during the actual build.</p>
  
  <p>I guess one solution would be to set up different builds for different environments such as test, stage and production.
  Looking into using vault to store my secrets in something like <code>&lt;PROJECTNAME&gt;/&lt;ENVIRONMENT&gt;/secret</code>.</p>
  
  <p>Any ideas on how to solve this problem?</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-11-05T22:20:35.147Z
Comments: TeamCity has a “password environment variable” which is hidden from the UI. As for the different variations, I’d recommend either using a build step before the build itself to deal with the different environments, or using multiple build configurations.
Comments: Birb
Tags: <continuous-integration><continuous-delivery><environment-variables><teamcity><secret-management>
Title: How to handle different credentials in continuous integration?
UserDisplayName: Cyclonecode
ThreadText: # How to handle different credentials in continuous integration?
  
  (Asked by: username_0 on 2019-07-20)
  
  I am using teamcity to automatically build and test a nodejs application. The problem I am facing is that the application needs to have some environment variables set during the build phase, as well as some secret variables that need to be set during the actual deployment (this is a manual step). These environment variables should be different depending on where the application should be deployed and I have no idea on how to solve this during the actual build.
  
  I guess one solution would be to set up different builds for different environments such as test, stage and production.
  Looking into using vault to store my secrets in something like `<PROJECTNAME>/<ENVIRONMENT>/secret`.
  
  Any ideas on how to solve this problem?
  
  **Tags:** continuous-integration, continuous-delivery, environment-variables, teamcity, secret-management
  
  > **Comments:**
  > **username_1**: TeamCity has a “password environment variable” which is hidden from the UI. As for the different variations, I’d recommend either using a build step before the build itself to deal with the different environments, or using multiple build configurations.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-07-20. Score: 1
  
  I'm not familiar with teamcity, but you can :
  
  * add a config folder in your repo, and inside this repo
  * create three files (staging.yml, preprod.yml, prod.yml).
  * on each file you will write down variables specific to each
    environment, and apply them within pipeline.
  
  For secrets, it's cautious to handle that manually or better use Vault.
  
  To not throw on error your pipeline/pods, set secrets as optional that could help if you want to set them later.
  
  > **Comments:**
  > **username_0**: obviously I do not want to add my secrets in the repository :)  
  > **username_0**: The problem is that I need to create a build which then can be deployed to different environments such as test, stage and production using different secrets such as api keys, passwords and more. The important thing here is that some settings also needs to be added to the environment in the actual build step.  
  
  ---
  
  ### Answer by username_2 on 2019-07-21. Score: 0
  
  If you are using kubernetes as deployment environment, you could use configmaps and apply them on building your code.
  
  > **Comments:**
  > **username_0**: As you can see in my question I am using teamcity =)  
  
  ---
  
  