Skip to content

Latest commit

 

History

History
65 lines (39 loc) · 3.41 KB

deploy-multiple-branches.md

File metadata and controls

65 lines (39 loc) · 3.41 KB
title description ms.topic ms.author author ms.date monikerRange recommendations
Deploy from multiple branches
DevOps CI CD - Use release pipelines to deploy from multiple branches to multiple stages.
tutorial
ninallam
ninallam
03/22/2021
>= azure-devops-2019
true

Deploy from multiple branches using Azure Pipelines

Azure Pipelines | 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.

Prerequisites

  • 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

  1. Select Releases under Pipelines. If this is your first release pipeline, select New Pipeline, otherwise select Create a release.

  2. Select Start with an empty job when prompted to select a template.

  3. Select Add an artifact and specify the project, the build pipeline, and the default version. Select Add when you are done.

    :::image type="content" source="media/add-artifact.png" alt-text="Add build artifact to release pipeline":::

  4. Select the Continuous deployment trigger icon and enable the Continuous deployment trigger to create a release every time a new build is available.

    :::image type="content" source="media/deploy-multiple-branches/ci-trigger.png" alt-text="Enable continuous deployment trigger":::

  5. 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.

    :::image type="content" source="media/dev-stage.png" alt-text="Configure Dev stage":::

  6. 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.

    :::image type="content" source="media/predeployment-trigger.png" alt-text="Set pre-deployment trigger to after release":::

  7. Enable the Artifact filters. Select Add and specify your artifact and build branch.

    :::image type="content" source="media/deploy-multiple-branches/artifact-filter1.png" alt-text="Enable Artifact filters":::

  8. 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.

    :::image type="content" source="media/deploy-multiple-branches/artifact-filter2.png" alt-text="Set up Prod with the main branch":::

  9. 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.

:::image type="content" source="media/deploy-multiple-branches/after-release.png" alt-text="Deployment status":::

Related articles