Documentation says:
Build.BuildId - The ID of the record for the completed build.
Build.BuildNumber - The name of the completed build, also known as the run number and that it can be customized.
Source: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables-devops-services
If you create a fresh build pipeline and do not customize BuildNumber format:
it will be given a unique integer as its name
In this case, is BuildNumber and BuildId exactly the same?
BuildId) is an internal immutable ID that is also referred to as the Run ID. It is unique across the organization. 2 (The third run will be 3, and so on.) Use $(Rev:r) to ensure that every completed build has a unique name.
If you use Visual Studio 2010, in the Team Explorer, select the related build definition, and right click it, and select Properties, there is Url, for example, vstfs:///Build/Definition/2, the number at the end of the Url is the build definition ID.
Azure DevOps ServerOpen the About page from the profile menu as shown in the following image. A page similar to the following image opens showing the version number.
If you need a unique ID in your version number, you can use the $ (Build.BuildId) predefined variable . This is an auto-incrementing integer that Azure DevOps increments after any build in your Azure DevOps organization; not just in your specific build pipeline. No two builds created in your Azure DevOps should ever have the same Build ID.
For classic build id and number are integers and are the same if not customized. For yml build pipeline and build id is an integer and build number consists of current date and number of tries per day. As per documentation the format is $ (Date:yyyyMMdd).$ (Rev:r).
This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag. The GUID of the TFS collection or Azure DevOps organization.
The name (i.e. Build number format) is what shows up on your Azure Pipeline’s build summary page.
No, it's not necessary the same. I just checked my classic and yml pipelines.
For classic
build id and number are integers and are the same if not customized.
For yml
build pipeline and build id is an integer and build number consists of current date and number of tries per day. As per documentation the format is $(Date:yyyyMMdd).$(Rev:r)
.
In this case, is BuildNumber and BuildId exactly the same?
Yes. When you don't customize BuildNumber format, the value of the two variables are the same.
Here is an example:
No define Build number:
output the two variables:
- powershell: |
echo $(build.buildid)
echo $(build.buildnumber)
displayName: 'PowerShell Script'
Result: The value is same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With