Skip to content

Commit a839631

Browse files
committed
Merged main into live
2 parents 893b22f + d83aad8 commit a839631

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

docs/pipelines/process/run-number.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Run and build numbers
2+
title: Configure run and build numbers
33
description: Learn about Azure Pipelines run numbers and build numbers and how you can configure them in your pipelines.
44
ms.topic: conceptual
55
ms.assetid: 7C469647-117D-4867-B094-8BC811C0003E
@@ -11,26 +11,23 @@ monikerRange: "<=azure-devops"
1111

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

14-
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.
1515

1616
The run number is used to identify a specific execution of a pipeline or build. The build number is synonymous with the run number.
1717

1818
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.
1919

2020
::: moniker range=">=azure-devops-2020"
2121

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

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`:
2825

2926
```yaml
30-
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:r)
27+
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd).$(Rev:r)
3128

3229
steps:
33-
- script: echo '$(Build.BuildNumber)'
30+
- script: echo '$(Build.BuildNumber)'
3431
```
3532
3633
::: moniker-end
@@ -87,7 +84,7 @@ The following table shows how each token resolves, based on the previous example
8784
>[!IMPORTANT]
8885
>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.
8986
>
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.
9188

9289
## Expressions
9390

@@ -154,7 +151,7 @@ steps:
154151

155152
### How can I reference the run number variable within a script?
156153

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 number directly as `$(Build.BuildNumber)` in your scripts, or create a custom variable that includes it. For example:
158155

159156
```yaml
160157
# Set MyRunNumber

0 commit comments

Comments
 (0)