4
votes

I have an angular project with dev and master branches and want the following: An test environment and production in Azure Devops. When something gets commited to dev I want the dev branch code to be deployed to the test environent, when code gets commited to master, I want the master branch to be deployed to the production environment.

My question is as follows: I need 2 artifacts based on "ng build --dev" and "ng build --prod". How can I achieve this? Do I need to add a "azure-pipelines.yml" file to the master and dev branch? If so, if I merge dev to master, the "azure-pipelines.yml" from dev gets merged with master... What is the best approach to this?

1
Hi M Yil, does Martin's answer helps to resolve your issue. Please let us know if you need any further help with this case. See this, just a reminder.LoLance

1 Answers

1
votes

I would recommend to use ng build --prod in all of your stages. You should have only one build stage for you app that builds the applications and publish the artifacts (binaries) to use them within your deployment stages (e. g. dev / prod).

Using this approach, you can test the same binaries in a test environment before you publish them to prod. In prod, you might use other configurations for your application, but the binaries itself should be the same.

Also, I would introduce an approvement-process before you deploy to your production environment instead of automatically deploy to it.

In short: Create a Multi-Stage-Pipeline that automatically builds the app and deploys it to your test environment after a push to dev / master. For the prod deployment, add approval checks and a condition to ensure that only builds from the master branch can deploy to that stage.