Bastien Vandamme
Bastien Vandamme

Reputation: 18485

How can I control my build number with Azure DevOps?

I get so many frustrations with Azure DevOps. In my Build number format I would like to have both

I'm not using YAML format. I use the classic interfaces with the option page to set my build format. At this moment I have this:

enter image description here

It work except each month the r number restart at 0. I want it to continue.

EDIT

enter image description here

I still didn't decided my final format. I would like to understand all the possibilities. Now I discovered the $(BuildID) property I have another question. Is it possible to have something similar to $(Rev:r) variable but that only check the left part of my build number.

Example:

4.16.$(SequenceFor[4.16]).$(BuildID)

In fact I would like to manually set the Major and Minor version and let the system update one by one the Build and use the Revision for the global $(BuildID).

Upvotes: 4

Views: 8740

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41785

The $(rev:r) is restarted when the build number changes in any character, so this is the reason why it's restarted whenever the major/minor or the sate changed.

So if you want to use an incremental unique number you can't use the $(rev:r) because then it will be restarted each build.

If you want a number that depends on the major and the minor numbers you need to use the counter expression:

Create 2 variables:

  1. major-minor = 4.16

And a variable that depends on his value and also is a counter:

  1. revision = $[ counter(variables['major-minor'],0) ]

enter image description here

The build number will be:

$(major-minor).$(revision).$(Build.BuildId)

Now, if you will change the major-minor (to 4.17 or 5.16) the revision will be again 0.

Upvotes: 8

Related Questions