0

I have set a variable with the value of a custom counter:

$[counter('myCounter', 0)]

I use this value to set the Build number format in the options tab:

v$(major).$(minor).$(myCounterVariable)

The first time I run it, it works fine, the value is 0 as it's using the counter. I have also checked the 'Settable at queue time' checkbox so that users can overwrite if they trigger the build pipeline manually. However, this doesn't carry through.

But what does work, is if I don't set the variable to the counter above and set it to a number, for example, 999, when I set it at queue time to be 567 for example, it gets overwritten by the 567, which is correct.

It seems as though the counter doesn't allow you to overwrite it.

Note

Before Christmas, this was working, I wonder if there has been a change in DevOps which removed the ability to override custom counters.

riQQ
  • 9,878
  • 7
  • 49
  • 66
thatOneGuy
  • 9,977
  • 7
  • 48
  • 90

1 Answers1

1

Custom counter can not be set at queue time in Azure DevOps Build Pipelines

Indeed, I could also reproduce this issue on my side. But I checked the two most recent Sprint Updates, but didn't find any updates about counter, so I could not sure if there has been a change in DevOps which removed the ability to override custom counters.

However, one thing we could be sure is that the custom counter can not be set at queue time, I found this issue is reported on our main forum for product issue:

Custom counter can not be set at queue time in Azure DevOps Build Pipelines

Looking forward to the Product Group to solve this problem as soon as possible, you could check the feedback from this ticket.

As workaround for this issue, we could add one more inline powershell task to the pipeline, and add a variable ManuallTriggerNumber and set the value is empty (also checked the 'Settable at queue time' checkbox ):

enter image description here

In the inline powershell task we use the Logging Command to set the build number:

Write-Host "##vso[build.updatebuildnumber]v$(major).$(minor).$(ManuallTriggerNumber)"

And set condition with:

and(succeeded(), ne(variables['$(ManuallTriggerNumber)'], 'Null'))

enter image description here

In this case, when we trigger the build pipeline manually, we could set the variable ManuallTriggerNumber value at queue time, the inline powershell will be invoked to update the build number based on the condition is true.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 1
    that's great, appreciate the workaround too, hoping for the counter override to be fixed soon, or at least a valid explanation as to why it has changed – thatOneGuy Jan 10 '20 at 10:09