Deploy from multiple branches using Azure Pipelines
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Artifact filters can be used with release triggers to deploy from multiple branches. Applying the artifact filter to a specific branch enables deployment to a specific stage when all the conditions are met.
A Git repository to create the pipeline. If you don't have one, use the pipelines-dotnet-core sample app.
A working build for your repository.
Set up a release pipeline
Select Releases under Pipelines. If this is your first release pipeline, select New Pipeline, otherwise select Create a release.
Select Start with an empty job when prompted to select a template.
Select Add an artifact and specify the project, the build pipeline, and the default version. Select Add when you are done.
Select the Continuous deployment trigger icon and enable the Continuous deployment trigger to create a release every time a new build is available.
Under Stages, select the stage and rename it to Dev. This stage will be triggered when a build artifact is published from the dev branch.
Select the Pre-deployment conditions icon in the Dev stage and set the deployment trigger to After release to trigger a deployment to this stage every time a new release is created.
Enable the Artifact filters. Select Add and specify your artifact and build branch.
Under Stage, select Add then New stage to add a new stage. Select Start with an empty job when prompted to select a template, and rename the stage to Prod. This stage will be triggered when a build artifact is published from the main branch. Repeat the steps 6-8 and replace the Build branch for this stage to main.
Add to each stage all the relevant deployment tasks to your environment.
Now the next time you have a successful build, the pipeline will detect which branch triggered that build and trigger deployment to the appropriate stage only.
Submit and view feedback for