You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pipelines/process/stages.md
+84-68Lines changed: 84 additions & 68 deletions
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ title: Stages in Azure Pipelines
3
3
description: Learn how to organize your jobs into stages, define dependencies, and set conditions. Understand how to implement deployment strategies and use YAML or a Classic pipeline to define stages.
A stage is a logical boundary in an Azure DevOps pipeline. Stages can be used to group actions in your software development process (for example, build the app, run tests, deploy to preproduction). Each stage contains one or more jobs.
14
+
A stage is a logical boundary in an Azure DevOps pipeline. Stages group actions in your software development process, like building the app, running tests, and deploying to preproduction. Each stage contains one or more jobs.
15
15
16
16
When you define multiple stages in a pipeline, by default, they run one after the other. Stages can also depend on each other. You can use the `dependsOn` keyword to define [dependencies](#specify-dependencies). Stages also can run based on the result of a previous stage with [conditions](#conditions).
17
17
@@ -26,13 +26,13 @@ You can also learn more about how stages relate to parts of a pipeline in the [Y
26
26
27
27
You can organize pipeline jobs into stages. Stages are the major divisions in a pipeline: build this app, run these tests, and deploy to preproduction are good examples of stages. They're logical boundaries in your pipeline where you can pause the pipeline and perform various checks.
28
28
29
-
Every pipeline has at least one stage even if you don't explicitly define it. You can also arrange stages into a dependency graph so that one stage runs before another one. There's a limit of 256 jobs for a stage.
29
+
Every pipeline has at least one stage, even if you don't explicitly define it. You can also arrange stages into a dependency graph so that one stage runs before another one. A stage can have up to 256 jobs.
30
30
31
31
::: moniker-end
32
32
33
33
#### [Classic](#tab/classic/)
34
34
Organize the deployment jobs in your release pipeline into stages.
35
-
Stages are the major divisions in your release pipeline: run functional tests, deploy to preproduction, and deploy to production are good examples of release stages.
35
+
Stages are the major divisions in your release pipeline. Examples include running functional tests, deploying to preproduction, and deploying to production.
36
36
37
37
<aname="approvals"></a><aname="conditions"></a>
38
38
A stage in a release pipeline consists of [jobs](../process/phases.md) and [tasks](../process/tasks.md).
@@ -50,49 +50,72 @@ and [queuing policies](#queuing-policies) control when a release gets deployed t
50
50
51
51
::: moniker range="<=azure-devops"
52
52
53
-
In the simplest case, you don't need any logical boundaries in your pipeline. In that case, you don't have to explicitly use the `stage` keyword. You can directly specify the jobs in your YAML file.
53
+
In the simplest case, you don't need logical boundaries in your pipeline. For those scenarios, you can directly specify the jobs in your YAML file without the `stages` keyword. For example, if you have a simple pipeline that builds and tests a small application without requiring separate environments or deployment steps, you can define all the jobs directly without using stages.
54
54
55
55
```yaml
56
-
# this has one implicit stage and one implicit job
57
56
pool:
58
57
vmImage: 'ubuntu-latest'
59
-
steps:
60
-
- bash: echo "Hello world"
58
+
59
+
jobs:
60
+
- job: BuildAndTest
61
+
steps:
62
+
- script: echo "Building the application"
63
+
- script: echo "Running tests"
61
64
```
62
65
66
+
This pipeline has one implicit stage and two jobs. The `stages` keyword isn't used because there's only one stage.
67
+
63
68
```yaml
64
-
# this pipeline has one implicit stage
65
69
jobs:
66
-
- job: A
70
+
- job: Build
67
71
steps:
68
-
- bash: echo "A"
72
+
- bash: echo "Building"
69
73
70
-
- job: B
74
+
- job: Test
71
75
steps:
72
-
- bash: echo "B"
76
+
- bash: echo "Testing"
73
77
```
74
78
75
-
If you organize your pipeline into multiple stages, you use the `stages` keyword.
79
+
To organize your pipeline into multiple stages, use the `stages` keyword. This YAML defines a pipeline with two stages where each stage contains multiple jobs, and each job has specific steps to execute.
76
80
77
81
```yaml
78
82
stages:
79
83
- stage: A
84
+
displayName: "Stage A - Build and Test"
80
85
jobs:
81
86
- job: A1
87
+
displayName: "Job A1 - build"
88
+
steps:
89
+
- script: echo "Building the application in Job A1"
90
+
displayName: "Build step"
82
91
- job: A2
92
+
displayName: "Job A2 - Test"
93
+
steps:
94
+
- script: echo "Running tests in Job A2"
95
+
displayName: "Test step"
83
96
84
97
- stage: B
98
+
displayName: "Stage B - Deploy"
85
99
jobs:
86
100
- job: B1
101
+
displayName: "Job B1 - Deploy to Staging"
102
+
steps:
103
+
- script: echo "Deploying to staging in Job B1"
104
+
displayName: "Staging deployment step"
87
105
- job: B2
106
+
displayName: "Job B2 - Deploy to Production"
107
+
steps:
108
+
- script: echo "Deploying to production in Job B2"
109
+
displayName: "Production deployment step"
88
110
```
89
111
90
-
If you choose to specify a `pool` at the stage level, then all jobs defined in that stage use that pool unless specified at the job-level.
91
-
92
112
::: moniker-end
93
113
94
114
::: moniker range="<=azure-devops"
95
115
116
+
If you specify a `pool` at the stage level, all jobs in that stage use that pool unless the stage is specified at the job level.
117
+
118
+
96
119
```yaml
97
120
stages:
98
121
- stage: A
@@ -103,24 +126,12 @@ stages:
103
126
pool: JobPool
104
127
```
105
128
106
-
The full syntax to specify a stage is:
107
-
108
-
```yaml
109
-
stages:
110
-
- stage: string # name of the stage, A-Z, a-z, 0-9, and underscore
111
-
displayName: string # friendly name to display in the UI
To add a stage to your release pipeline, select the release pipeline in **Releases** page, select the action to **Edit** it, and then select the **Pipeline** tab.
134
+
To add a stage to your release pipeline, select the release pipeline on the **Releases** page, select **Edit**, and then select the **Pipeline** tab.
124
135
While the most important part of defining a stage is the
125
136
automation tasks, you can also configure several properties and options
126
137
for a stage in a release pipeline. You can:
@@ -129,7 +140,7 @@ for a stage in a release pipeline. You can:
129
140
* Designate one user or a
130
141
group to be the stage owner. Stage owners get
131
142
notified whenever a deployment to that
132
-
stage fails. Being a stage owner doesn't automatically come with any permissions.
143
+
stage fails. Stage ownership doesn't automatically include permissions.
133
144
* Delete the stage from the pipeline.
134
145
* Change the order of stages.
135
146
* Save a copy of the stage as a [stage template](../release/env-templates.md).
@@ -145,77 +156,82 @@ for a stage in a release pipeline. You can:
145
156
146
157
::: moniker range="<=azure-devops"
147
158
148
-
When you define multiple stages in a pipeline, by default, they run sequentially in the order in which you define them in the YAML file. The exception to this is when you add dependencies. With dependencies, stages run in the order of the `dependsOn` requirements.
159
+
When you define multiple stages in a pipeline, they run sequentially by default in the order you define them in the YAML file. The exception to this is when you add dependencies. With dependencies, stages run in the order of the `dependsOn` requirements.
149
160
150
161
Pipelines must contain at least one stage with no dependencies.
151
162
152
-
The syntax for defining multiple stages and their dependencies is:
163
+
For more information on how to define stages, see [stages in the YAML schema](/azure/devops/pipelines/yaml-schema/stages).
153
164
154
-
```yaml
155
-
stages:
156
-
- stage: string
157
-
dependsOn: string
158
-
condition: string
159
-
```
165
+
The following example stages run sequentially. If you don't use a `dependsOn` keyword, stages run in the order they're defined.
160
166
161
-
Example stages that run sequentially:
162
167
163
168
```yaml
164
-
# if you do not use a dependsOn keyword, stages run in the order they are defined
165
169
stages:
166
-
- stage: QA
170
+
- stage: Build
171
+
displayName: "Build Stage"
167
172
jobs:
168
-
- job:
169
-
...
173
+
- job: BuildJob
174
+
steps:
175
+
- script: echo "Building the application"
176
+
displayName: "Build Step"
170
177
171
-
- stage: Prod
178
+
- stage: Test
179
+
displayName: "Test Stage"
172
180
jobs:
173
-
- job:
174
-
...
181
+
- job: TestJob
182
+
steps:
183
+
- script: echo "Running tests"
184
+
displayName: "Test Step"
175
185
```
176
186
177
187
Example stages that run in parallel:
178
188
179
189
```yaml
180
190
stages:
181
191
- stage: FunctionalTest
192
+
displayName: "Functional Test Stage"
182
193
jobs:
183
-
- job:
184
-
...
194
+
- job: FunctionalTestJob
195
+
steps:
196
+
- script: echo "Running functional tests"
197
+
displayName: "Run Functional Tests"
185
198
186
199
- stage: AcceptanceTest
187
-
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel
200
+
displayName: "Acceptance Test Stage"
201
+
dependsOn: [] # Runs in parallel with FunctionalTest
188
202
jobs:
189
-
- job:
190
-
...
203
+
- job: AcceptanceTestJob
204
+
steps:
205
+
- script: echo "Running acceptance tests"
206
+
displayName: "Run Acceptance Tests"
191
207
```
192
208
193
-
Example of fan-out and fan-in:
209
+
Example of fan-out and fan-in behavior:
194
210
195
211
```yaml
196
212
stages:
197
213
- stage: Test
198
214
199
215
- stage: DeployUS1
200
-
dependsOn: Test # this stage runs after Test
216
+
dependsOn: Test # stage runs after Test
201
217
202
218
- stage: DeployUS2
203
-
dependsOn: Test # this stage runs in parallel with DeployUS1, after Test
219
+
dependsOn: Test # stage runs in parallel with DeployUS1, after Test
204
220
205
221
- stage: DeployEurope
206
-
dependsOn: # this stage runs after DeployUS1 and DeployUS2
222
+
dependsOn: # stage runs after DeployUS1 and DeployUS2
207
223
- DeployUS1
208
224
- DeployUS2
209
225
```
210
226
211
227
::: moniker-end
212
228
213
229
#### [Classic](#tab/classic/)
214
-
You control the dependencies by setting the triggers on each stage of the release pipeline:
230
+
Control dependencies by setting triggers on each stage of the release pipeline:
215
231
216
-
* Stages run with a trigger or by being manually started.
217
-
* With an **After release** trigger, a stage starts as soon as the release starts, in parallel with other stages that have **After release** trigger.
218
-
* With an **After stage** trigger, a stage will start after all the dependent stages complete. Using this, you can model fan-out and fan-in behavior for stages.
232
+
* Stages run with a trigger or are manually started.
233
+
* With an **After release** trigger, a stage starts as soon as the release begins, running in parallel with other stages that have the same trigger.
234
+
* With an **After stage** trigger, a stage starts after all dependent stages complete. Using this, you can model fan-out and fan-in behavior for stages.
219
235
220
236
* * *
221
237
@@ -275,12 +291,12 @@ When you specify **After release** or **After stage** triggers, you can also spe
275
291
276
292
#### [YAML](#tab/yaml/)
277
293
::: moniker range="<=azure-devops"
278
-
YAML pipelines don't support queuing policies. Each run of a pipeline is independent from and unaware of other runs. In other words, your two successive commits may trigger two pipelines, and both of them will execute the same sequence of stages without waiting for each other. While we work to bring queuing policies to YAML pipelines, we recommend that you use [manual approvals](approvals.md) in order to manually sequence and control the order the execution if this is of importance.
294
+
YAML pipelines don't support queuing policies. Each run of a pipeline is independent from and unaware of other runs. In other words, your two successive commits might trigger two pipelines, and both of them will execute the same sequence of stages without waiting for each other. While we work to bring queuing policies to YAML pipelines, we recommend that you use [manual approvals](approvals.md) in order to manually sequence and control the order the execution if this is of importance.
279
295
::: moniker-end
280
296
281
297
#### [Classic](#tab/classic/)
282
-
In some cases, you may be able to generate builds faster than
283
-
they can be deployed. Alternatively, you may configure multiple
298
+
In some cases, you might be able to generate builds faster than
299
+
they can be deployed. Alternatively, you might configure multiple
284
300
[agents](../agents/agents.md) and, for example, be creating releases from the same release pipeline
285
301
for deployment of different artifacts. In such cases, it's useful to
286
302
be able to control how multiple releases are queued into a
@@ -370,14 +386,14 @@ In the following example, the development stage runs automatically, while the pr
370
386
371
387
```yaml
372
388
stages:
373
-
- stage: development
389
+
- stage: Development
374
390
displayName: Deploy to development
375
391
jobs:
376
392
- job: DeployJob
377
393
steps:
378
394
- script: echo 'hello, world'
379
395
displayName: 'Run script'
380
-
- stage: production
396
+
- stage: Production
381
397
displayName: Deploy to production
382
398
trigger: manual
383
399
jobs:
@@ -389,9 +405,9 @@ stages:
389
405
390
406
## Mark a stage as unskippable
391
407
392
-
Mark a stage as `isSkippable: false` to prevent pipeline users from skipping stages. For example, you may have a YAML template that injects a stage that performs malware detection in all pipelines. If you set `isSkippable: false` for this stage, Pipeline won't be able to skip malware detection.
408
+
Mark a stage as `isSkippable: false` to prevent pipeline users from skipping stages. For example, you might have a YAML template that injects a stage that performs malware detection in all pipelines. If you set `isSkippable: false` for this stage, your pipeline won't be able to skip malware detection.
393
409
394
-
In the following example, the Malware detection stage is marked as non-skippable, meaning it must be executed as part of the pipeline run.
410
+
In the following example, the Malware detection stage is marked as nonskippable, meaning it must be executed as part of the pipeline run.
395
411
396
412
```yaml
397
413
- stage: malware_detection
@@ -402,7 +418,7 @@ In the following example, the Malware detection stage is marked as non-skippable
402
418
...
403
419
```
404
420
405
-
When a stage is non-skippable, it will show with a disabled checkbox in the **Stages to run** configuration panel.
421
+
When a stage is nonskippable, it shows with a disabled checkbox in the **Stages to run** configuration panel.
406
422
407
423
:::image type="content" source="media/stages/stages-run-skip-stage.png" alt-text="Screenshot of stages to run with disabled stage. ":::
0 commit comments