0
votes

currently I'm bussy creating an CI/CD for my angular frontend project. I have a specific git strategy but and have a CI/CD question regarding that:

We have a master/dev branch branches. What I want is the following:

  • When I commit code to the dev branch, I want the CI to create an artifact and deploy it to a test environment.
  • When I commit code to the master branch, I want the CI to create an artifact and deploy that to the production environment.

Do I need to build two different artifacts or just one? Because for the production and test environment I have different project configurations. For example: I want my project to connect with the production database if it's deployed in the production environment.

1

1 Answers

1
votes

Best practice is to build one artifact and apply different configurations when deploying to multiple environments.

In Angular, you can use a config.json file to store environment related information. You can create one file for each environment and store them as secure files in Azure DevOps. Before deploying, download and copy the related file into your artifact.

You can also store each configuration keys/values as variables and replace it in your config.json file using File Transform task.