I use the old Azure Pipeline (with UI, no yaml) with a self-hosted agent. In order to version my project I did the following: I declared two variables on the tab "Variables" named Major
and Minor
. Then I declared the variable Revision
with the following value: $[counter(format('{0}.{1}', variables['Major'], variables['Minor']),11)]
(you may ask why the revision starts with 11. That is simply the prerequisite for my project, I cannot change it). Finally, I declared the variable named Version
with the value $(Major).$(Minor).$(Revision).0
.
Summarized (the values for major and minor were chosen at random):
Major = 1
Minor = 2
Revision = $[counter(format('{0}.{1}', variables['Major'], variables['Minor']),11)]
Version = $(Major).$(Minor).$(Revision).0
The code above means that the version is incremented starting with the number 11 for the Revision
:
1.2.11.0 // first run
1.2.12.0 // second run
1.2.13.0 // third run
and so on
The question is: How can I force the pipeline to reset the value that was saved for the counter? I already tried to delete Revision
and Version
(and thus also the counter), tried to delete the .json
file with the settings for the current pipeline, but it seems to have nothing to do with the counter value. The only thing that helped me was the cloned version of the pipeline. For this cloned version the counter is set to 11 again.
Of course, I have seen How to reset VSTS counter?. Unfortunately, I cannot use the proposed solution. In addition, the mentioned question is relatively old and I thought someone might have found another solution.
Note: One possible workaround (not solution!) for the counter resetting with yaml
pipilines would be the following:
- name: Major
value: '1'
- name: Minor
value: '2'
- name: Revision
value: $[counter(format('{0}',variables['Token']),11)]
- name: Token
value: '09.02.2025-0'
- name: Version
value: $(Major).$(Minor).$(Revision).0
In this code, the counter value is linked with the variable Revision
, and the counterId depends on the variable Token
.
For instance, suppose version 1.2.11
was built and you want to build the exact same version again.
As long as you do not change Token
, the counter will increment from its previous value in each build. In order to set the counter back to 1.2.11
, you must change the Token
variable to a value you have not used before - such as value: 09.02.2025-1
. Once you do that and start the build, a completely new counter with a new counterId
will be created and associated with the value 11
from $[counter(format('{0}',variables['Token']),11)]
.
The key point with this workaround is that all old counters remain somewhere in the background; you just do not see them. You can still access them if you revert Token
to a value that was previously used. Unfortunately, Microsoft has not yet addressed this counter issue here.
Unfortunately, there is no default way to reset the counter yet. You may submit a suggestion at website below:
https://developercommunity.visualstudio.com/content/idea/post.html?space=21