Skip to content

Commit 7cd76cf

Browse files
authored
Merge pull request #9065 from MicrosoftDocs/pipelines/549194
Deploy to multiple stages
2 parents 6e38f37 + 43fb9b0 commit 7cd76cf

8 files changed

Lines changed: 81 additions & 42 deletions

docs/pipelines/get-started/pipelines-get-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ For instructions, see [build](../build/ci-build-git.md) and [deploy](../release/
4949
|-------------------------------------------------------|------------------------------------------------------------------------------------------------|------------------|------------------|-----------------|
5050
| **Agents** | A software component that runs on a virtual machine or a physical machine and is responsible for executing the tasks defined in your Azure Pipelines. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) |
5151
| **Approvals** | Control your deployment workflow by requiring designated approvers to approve before deploying to a stage. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/approvals.md#approvals) | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/approvals/approvals.md#predeployment-approvals) |
52-
| **Artifacts** | Download and publish your binaries and various types of packages to different destinations. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/deploy-multiple-branches.md#create-a-release-pipeline) |
52+
| **Artifacts** | Download and publish your binaries and various types of packages to different destinations. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/deploy-multiple-branches.md#create-a-classic-release-pipeline) |
5353
| **Caching** | Reduce build time by caching and reusing dependencies from previous runs. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/caching.md) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/caching.md) | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: |
5454
| **Conditions** | Specify conditions under which a step, job, or stage should run. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=yaml) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=classic) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=classic) |
5555
| **Container jobs** | Specify jobs to run in a container. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/container-phases.md) | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: |
@@ -78,7 +78,7 @@ For instructions, see [build](../build/ci-build-git.md) and [deploy](../release/
7878
|-------------------------------------------------------|------------------------------------------------------------------------------------------------|------------------|------------------|-----------------|
7979
| **Agents** | A software component that runs on a virtual machine or a physical machine and is responsible for executing the tasks defined in your Azure Pipelines. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md) |
8080
| **Approvals** | Control your deployment workflow by requiring designated approvers to approve before deploying to a stage. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/approvals.md#approvals) | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/approvals/approvals.md#predeployment-approvals) |
81-
| **Artifacts** | Download and publish your binaries and various types of packages to different destinations. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/deploy-multiple-branches.md#create-a-release-pipeline) |
81+
| **Artifacts** | Download and publish your binaries and various types of packages to different destinations. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../artifacts/pipeline-artifacts.md?&tabs=yaml-task) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../release/deploy-multiple-branches.md#create-a-classic-release-pipeline) |
8282
| **Conditions** | Specify conditions under which a step, job, or stage should run. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=yaml) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=classic) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/conditions.md?tabs=classic) |
8383
| **Container jobs** | Specify jobs to run in a container. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../process/container-phases.md) | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: | :::image type="icon" source="../../media/icons/delete-icon.png" border="false"::: |
8484
| **Demands** | Ensure that the capabilities your pipeline needs are present on the running agent. | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md#configure-demands) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md?tabs=classic#configure-demands) | :::image type="icon" source="../../media/icons/checkmark.png" border="false"::: [doc](../agents/agents.md?tabs=classic#configure-demands) |
Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,124 @@
11
---
2-
title: Deploy to different stages from multiple branches
3-
description: Learn how to use Classic release pipelines to deploy to different stages from multiple branches.
2+
title: Deploy multiple branches to different stages
3+
description: Learn how to use Classic release pipelines to deploy from multiple branches to different stages.
44
ms.topic: tutorial
5-
ms.date: 08/06/2024
5+
ms.date: 03/23/2026
66
monikerRange: "<=azure-devops"
77
"recommendations": "true"
88
---
99

10-
# Deploy to different stages from multiple branches using Classic release pipelines
10+
# Deploy multiple branches to different stages with Classic release pipelines
1111

1212
[!INCLUDE [version-lt-eq-azure-devops](../../includes/version-lt-eq-azure-devops.md)]
1313

14-
Classic release pipelines provide a convenient graphical user interface for setting up a continuous delivery solution for your application. Classic releases can be configured to trigger deployments automatically whenever a new artifact is available. Artifact filters can be used with release triggers to deploy from multiple branches. By applying artifact filters to specific branches, you can control deployment to particular stages based on your needs.
15-
16-
In this article, you'll learn how to:
17-
18-
> [!div class="checklist"]
19-
> * Enable continuous deployment triggers.
20-
> * Release from multiple branches.
21-
> * Deploy to multiple stages.
14+
Classic release pipelines provide a graphical way to set up continuous delivery for your application. You can configure a release to trigger automatically when a new artifact is available, and then use artifact filters to map specific branches to specific stages. This approach lets you deploy each branch to the stage you intend. This article walks you through how to configure a Classic release pipeline that deploys to different stages based on the source branch.
2215

2316
## Prerequisites
2417

25-
- An Azure DevOps organization and a project. Create an [organization](../../organizations/accounts/create-organization.md) or a [project](../../organizations/projects/create-project.md#create-a-project) if you haven't already.
18+
| **Product** | **Requirements** |
19+
|--------------------|-------------------|
20+
| **Azure DevOps** | - An [Azure DevOps organization](../../organizations/accounts/create-organization.md).<br> - An [Azure DevOps project](../../organizations/projects/create-project.md).<br> - A working pipeline set up for your repository to build your project and generate a pipeline artifact. [Create a Classic pipeline](create-classic-pipelines.md) if you don't have one already. |
2621

27-
- A working pipeline set up for your repository to build your project and generate a pipeline artifact. [Create your first pipeline](../create-first-pipeline.md) if you don't have one already.
22+
## Create a Classic release pipeline
2823

29-
## Create a release pipeline
24+
In this section, you create the base Classic release pipeline and configure the first stage (**Dev**). You add an artifact source, enable automatic release creation, and apply an artifact filter so this stage runs only when the build comes from the *Dev* branch.
3025

3126
1. Sign in to your Azure DevOps organization, and then navigate to your project.
3227

33-
1. Select **Pipelines** > **Releases**. If this is your first release pipeline, select **New Pipeline**, otherwise select **New** > **New release pipeline**.
28+
1. Select **Pipelines** > **Releases**.
29+
30+
1. Create a new Classic release pipeline:
31+
32+
- If this is your first release pipeline, select **New Pipeline**.
33+
- If you already have release pipelines, select **New** > **New release pipeline**.
34+
35+
1. In the template picker, select **Start with an empty job**.
36+
37+
1. Under **Stages**, select the default stage and rename it to **Dev**. In the next steps, you configure this stage to deploy only when an artifact is produced from the *Dev* branch.
3438

35-
1. When prompted to select a template, select **Start with an empty job**.
39+
:::image type="content" source="media/rename-stage-classic-release.png" alt-text="A screenshot displaying how to rename a stage in a Classic release pipeline.":::
3640

37-
1. Under **Stages**, select the stage and rename it to **Dev**. The following steps show how to configure this stage to be triggered when an artifact is published from the *Dev* branch.
41+
1. Under **Artifacts**, select **Add**.
3842

39-
:::image type="content" source="media/dev-stage.png" alt-text="A screenshot displaying how to rename a stage in a Classic release pipeline.":::
43+
1. Configure the artifact source:
4044

41-
1. Under **Artifacts**, select **Add** to add an artifact. Specify your **Source type** and fill out the required fields (these vary based on the selected source type). Select **Add** when you're done.
45+
- Select your **Source type**.
46+
- Complete the required fields for that source type, such as project, pipeline, and default version.
47+
- Select **Add**.
4248

43-
:::image type="content" source="media/add-artifact.png" alt-text="A screenshot that shows how to add an artifact to a Classic release pipeline.":::
49+
:::image type="content" source="media/add-artifact-to-classic-release.png" alt-text="A screenshot that shows how to add an artifact to a Classic release pipeline.":::
4450

45-
1. Select the **Continuous deployment trigger** icon, and then enable the **Continuous deployment trigger** to create a release whenever a new artifact is available.
51+
1. Select the **Continuous deployment trigger** icon on the artifact, and then turn on **Continuous deployment trigger** to create a release whenever a new artifact is available.
4652

47-
:::image type="content" source="media/enable-continuous-deployment-trigger.png" alt-text="A screenshot displaying how to enable the continuous deployment trigger.":::
53+
:::image type="content" source="media/enable-continuous-deployment-trigger.png" alt-text="A screenshot displaying how to enable the continuous deployment trigger in a Classic release pipeline.":::
4854

49-
1. In the Dev stage, select the **Pre-deployment conditions** icon and set the deployment trigger to **After release**. This will trigger a deployment to this stage whenever a new release is created.
55+
1. In the **Dev** stage, select the **Pre-deployment conditions** icon.
5056

51-
:::image type="content" source="media/predeployment-trigger.png" alt-text="A screenshot that shows how to configure the pre-deployment conditions.":::
57+
1. Set **Deployment trigger** to **After release** so the stage starts automatically whenever a new release is created.
5258

53-
1. while still in **Pre-deployment conditions**, enable **Artifact filters**, select **Add**, and then specify the artifact you selected earlier and set the **Build branch** to *Dev*.
59+
1. Still in **Pre-deployment conditions**, configure branch-based filtering:
60+
61+
- Turn on **Artifact filters**.
62+
- Select **Add**.
63+
- Select the artifact you added earlier.
64+
- Set **Build branch** to *Dev*.
65+
66+
With this filter in place, the **Dev** stage deploys only when the release is created from a build of the *Dev* branch.
67+
68+
:::image type="content" source="media/configure-deployment-conditions-development-stage.png" alt-text="A screenshot displaying how to set up the pre-deployment conditions in a Classic release pipeline.":::
5469

55-
:::image type="content" source="media/predeployment-conditions-artifact-filters.png" alt-text="A screenshot displaying how to set up the Artifact filters in Pre-deployment conditions.":::
5670

5771
## Add a new stage
5872

73+
In this section, you add a second stage (**Prod**) to the same release pipeline and configure it to deploy only when artifacts are built from the *main* branch. This lets you keep branch-to-stage routing consistent across environments.
74+
5975
1. Sign in to your Azure DevOps organization, and then navigate to your project.
6076

61-
1. Select **Pipelines** > **Releases**, select your release pipeline, and then select **Edit**.
77+
1. Select **Pipelines** > **Releases**, open the release pipeline you created earlier, and then select **Edit**.
6278

63-
1. Under **Stages**, select **Add** > **New stage** to add a new stage.
79+
1. Under **Stages**, select **Add** > **New stage**.
6480

65-
1. Select **Start with an empty job** when prompted to select a template.
81+
1. In the template picker, select **Start with an empty job**.
82+
83+
1. Select the new stage and rename it to **Prod**. In the next steps, you configure this stage so it deploys only when the artifact comes from the *main* branch.
6684

67-
1. Select your new stage and rename it to **Prod**. The following steps show how to configure this stage to trigger when an artifact is published from the *main* branch.
85+
1. In the **Prod** stage, select the **Pre-deployment conditions** icon.
6886

69-
1. Select your *Prod* stage, select the **Pre-deployment conditions** icon, and set the deployment trigger to **After release**. This ensures deployment to this stage whenever a new release is created.
87+
1. Set **Deployment trigger** to **After release** so this stage can start automatically when a new release is created.
7088

71-
1. Select the toggle button to enable **Artifact filters**. Select **Add**, and then specify the artifact you selected earlier and set the **Build branch** to *main*.
89+
1. Still in **Pre-deployment conditions**, configure branch-based filtering for production:
7290

73-
:::image type="content" source="media/predeployment-conditions-prod.png" alt-text="A screenshot displaying how to configure predeployment conditions for the Prod stage.":::
91+
- Turn on **Artifact filters**.
92+
- Select **Add**.
93+
- Select the same artifact source you configured earlier.
94+
- Set **Build branch** to *main*.
95+
96+
With this filter in place, the **Prod** stage deploys only when the release is created from a build of the *main* branch.
97+
98+
:::image type="content" source="media/configure-deployment-conditions-production-stage.png" alt-text="A screenshot displaying how to configure pre-deployment conditions for the production stage in a Classic release pipeline.":::
7499

75100
## Deploy to a specific stage
76101

77-
Now that you've set up your stages, every time a new artifact is available, the release pipeline will detect which branch triggered the build and deploy only to the appropriate stage.
102+
At this point, your release pipeline is configured to route deployments by branch: artifacts from the *Dev* branch deploy to the **Dev** stage, and artifacts from the *main* branch deploy to the **Prod** stage. Use the following checks to validate that the branch filters are working as expected.
103+
104+
1. Trigger a build from the *Dev* branch so a new artifact version is published.
105+
106+
1. Open **Pipelines** > **Releases**, and then open the newly created release.
107+
108+
1. Verify that the **Dev** stage starts (or is queued), and that the **Prod** stage is skipped because the artifact branch doesn't match its filter.
109+
110+
1. Trigger a second build from the *main* branch.
111+
112+
1. Open the new release and verify the opposite behavior: the **Prod** stage starts, and the **Dev** stage is skipped.
113+
114+
1. If a stage doesn't behave as expected, open that stage's **Pre-deployment conditions** and confirm the **Artifact filters** branch value and selected artifact source.
115+
116+
By validating both branch paths, you can confirm that each environment deploys only from the branch intended for that stage.
117+
118+
## Related content
78119

79-
:::image type="content" source="media/deploy-to-specific-stage.png" alt-text="A screenshot displaying deployment to a specific stage.":::
120+
- [Create a multi-stage release pipeline](define-multistage-release-process.md)
80121

81-
## Related articles
122+
- [Use variables in Classic release pipelines](variables.md)
82123

83-
- [Artifact sources](artifacts.md)
84-
- [Release triggers](triggers.md)
85124
- [Deploy pull request Artifacts](deploy-pull-request-builds.md)

0 commit comments

Comments
 (0)