1

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?

1
  • 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.
    – Birb
    Commented Nov 5, 2019 at 22:20

2 Answers 2

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.

2
  • 1
    obviously I do not want to add my secrets in the repository :) Commented Jul 20, 2019 at 20:25
  • 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. Commented Jul 21, 2019 at 14:49
0

If you are using kubernetes as deployment environment, you could use configmaps and apply them on building your code.

1
  • As you can see in my question I am using teamcity =) Commented Jul 21, 2019 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.