5
votes

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://docs.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?

3

3 Answers

2
votes

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

enter image description here

1
votes

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:

enter image description here

output the two variables:

- powershell: |
   echo $(build.buildid)
   
   echo $(build.buildnumber)
  displayName: 'PowerShell Script'

Result: The value is same.

enter image description here

0
votes

No, when you create a new build pipeline without customize the build number it will be the same as the build id + the commit message.

For example (4348 is the build id):

4348 test commit