0

Working with Gated/CI build definition (vNext) in TFS2017, the revision number is not increased correctly. Each build has the same Rev number even the changes are checked-in properly.

I get the revision number from $Env:BUILD_BUILDNUMBER via powershell at the beginning of the build process and it always returns the same number.

Felipe
  • 17
  • 3

1 Answers1

0

Make sure you are using the $(Rev:.r) token in the Build number format setting.

Build number format:

Use $(Rev:.r) to ensure that every completed build has a unique name. When a build is completed, if nothing else in the build number has changed, the Rev integer value is incremented by one.

If you want to show prefix zeros in the number, you can add additional 'r' characters. For example, specify $(rev:.rr) if you want the Rev number to begin with 01, 02, and so on.

Also make sure the build number was not updated with the permanent number or string. (There is a possibility that used a script to customize your build process that updated the build number)


UPDATE1:

Please note that if the Major build number is changed in Build number format, then the revision number will not be changed. The Revision number only incremented when the Major part is not changed.

BTW, the token $(rev:.rr) should be used such as a variable, so the build number format should be something like : Test DEV CI_Rev.$(rev:.rr) in your scenario.


UPDATE2:

In your scenario you updated the build number with the assembly info every time. So, if the assembly info is different every time, then the revision number will no be changed, that's the expected behavior.

enter image description here

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • My Build number format is: `Test DEV CI_Rev.(rev:.rr)` But I update the build number by **Test 1.8.0.8 DEV CI.01** I've created a variable like "Test Ver DEV CI.Rev" where "Ver" is replaced with AssemblyInfo and "Rev" with Revision number. Reading the above information, the revision only change if "Build number format" does not change, am I correct? – Felipe Jun 06 '18 at 13:44
  • @Felipe Yes, if the Major build number is changed in `Build number format`, then the revision number will not be changed. The Revision number only incremented when the Major part is not changed. BTW, the $(rev:.rr) should be used such as a variable, so the build number format should be something like : `Test DEV CI_Rev.$(rev:.rr)` in your scenario. – Andy Li-MSFT Jun 07 '18 at 01:55
  • @Felipe Please see the updated answer, especially for the **bold** words. – Andy Li-MSFT Jun 07 '18 at 02:00
  • sorry I already had $(rev:.rr). But what do you mean with "Major part", because you can put anything that you want. – Felipe Jun 07 '18 at 12:14
  • @Felipe The "Major part" means the major build number, for example assume the final build number is `2018Test.1`, then the major part I mentioned should be `2018Test`. When you use the token `$(rev:.r)`, if the build number `2018Test` is not changed next time, then the next final build number should be `2018Test.2`. But if the build number `2018Test` is changed, e.g changed to `2018Test-v`, then the revision will not be changed any more, the final build number maybe `2018Test-v.1` – Andy Li-MSFT Jun 08 '18 at 01:26
  • Thanks, now I understand better. In my case is changed everytime due the update of the assembly. But this approach is different than XAML builds where the revision changed in each build independently of the major part. – Felipe Jun 11 '18 at 09:47
  • @Felipe So, if the assembly info is different every time, then the revision number will no be changed, that's the expected behavior. BTW, if I have answered you questions, could you please vote it up and [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), This can be beneficial to other community members reading this thread. – Andy Li-MSFT Jun 12 '18 at 01:35