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
Azure Pipelines assigns a unique run number (also called a build number) to each pipeline execution. You can customize these numbers to make them more meaningful for your team, using variables, tokens, and naming patterns.
15
+
14
16
This article explains how Azure Pipelines build numbers and run numbers are constructed, and how you can customize them in your pipelines.
15
17
16
18
The run number is used to identify a specific execution of a pipeline or build. The build number is synonymous with the run number.
@@ -19,18 +21,17 @@ If you don't specify a build name in YAML pipelines, or you leave the **Name** f
19
21
20
22
::: moniker range=">=azure-devops-2020"
21
23
22
-
In YAML pipelines, the build name property is called `name` and must be at the root level of a pipeline. Items specified at the root level of a YAML file are [pipeline](/azure/devops/pipelines/yaml-schema/pipeline)properties.
24
+
You can only customize the run number at the root level of the pipeline with the `name`property. The `name` property is set at the [pipeline](/azure/devops/pipelines/yaml-schema/pipeline)level.
23
25
24
-
>[!NOTE]
25
-
>The `name` property doesn't work in template files.
26
+
The `name` property only works at the pipeline root and not in templates or stages.
26
27
27
-
The following example code outputs a customized build number like **project_def_master_202408281**.
28
+
The following example code outputs a customized number like `project_def_main_20240828.1`.
@@ -87,7 +88,7 @@ The following table shows how each token resolves, based on the previous example
87
88
>[!IMPORTANT]
88
89
>If you want to show prefix zeros in the run number, you can add more `r` characters to the `Rev` token. For example, specify `$(Rev:rr)` if you want the `Rev` number to begin with `01`, `02`, and so on.
89
90
>
90
-
>If you use a zero-padded `Rev` as part of a version numbering scheme, be aware that some pipeline tasks or popular tools, like NuGet packages, remove the leading zeros. This behavior causes a version number mismatch in the artifacts that are produced.
91
+
>If you use a zero-padded `Rev` as part of a version numbering scheme, some pipeline tasks or popular tools, like NuGet packages, remove the leading zeros. This behavior causes a version number mismatch in the artifacts that are produced.
91
92
92
93
## Expressions
93
94
@@ -154,7 +155,7 @@ steps:
154
155
155
156
### How can I reference the run number variable within a script?
156
157
157
-
You can define a new variable that includes the run number, or call the run number directly. In the following example, `$(MyRunNumber)` is a new variable that includes the run number. You can call the run number variable by using `MyRunNumber` or `$(Build.BuildNumber)`.
158
+
You can reference the run numberdirectly as `$(Build.BuildNumber)` in your scripts, or create a custom variable that includes it. For example:
0 commit comments