I have a working yaml build pipeline where I maintain the major, minor and patch versions of my app. The revision is calculated by the pipeline with this expression:
revision: $[counter(variables['squilversionkey'], 0)]
(The key is calculated from the other variables to give something like "1.1.20-dev".)
In the same pipeline, I pass this to a script that sets the revision and combined versions (such as "1.1.20.11-dev") in some text files so that the app knows its version. So far, that works.
Ideally though, I don't want to maintain the major, minor and patch versions in the same yaml file. It's a complicated file and I don't want to see it as changed in the commit history just because the versions are bumped when the logic isn't changed.
In order to have those in a different file, I need to read those values into the pipeline though (they are no longer in the yaml). That works in principle:
Write-Output "##vso[task.setvariable variable=squilversionkey]$baseVersion"
This should give me the variable to use in the counter expression, right?
Alas, the counter expression needs to be "dynamic" (in square brackets), and those can only appear in variable definitions and conditions - not in the env sections of tasks.
Tasks can also not have variable definitions of their own, only jobs. But a new job will have forgotten the variable and it also seems a bit overkill to bother a second job.
What's a good way to do this?





