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
This article explains how Azure Pipelines build numbers and run numbers are constructed, and how you can customize them in your pipelines.
14
+
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
15
16
16
The run number is used to identify a specific execution of a pipeline or build. The build number is synonymous with the run number.
17
17
18
18
If you don't specify a build name in YAML pipelines, or you leave the **Name** field blank in Classic pipelines, your run gets a unique integer as its name. You can give runs more useful names that are meaningful to your team. You can use a combination of tokens, variables, and underscore characters in build names.
19
19
20
20
::: moniker range=">=azure-devops-2020"
21
21
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.
22
+
You can only customize the run number at the root level of your pipeline using the `name` property. Set the `name` property at the [pipeline](/azure/devops/pipelines/yaml-schema/pipeline)level. The `name` property isn't supported in templates or stages.
23
23
24
-
>[!NOTE]
25
-
>The `name` property doesn't work in template files.
26
-
27
-
The following example code outputs a customized build number like **project_def_master_202408281**.
24
+
The following code sets a custom run number format like `project_def_main_202408281`:
@@ -87,7 +84,7 @@ The following table shows how each token resolves, based on the previous example
87
84
>[!IMPORTANT]
88
85
>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
86
>
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.
87
+
>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
88
92
89
## Expressions
93
90
@@ -154,7 +151,7 @@ steps:
154
151
155
152
### How can I reference the run number variable within a script?
156
153
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)`.
154
+
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