Tuesday, October 26, 2021

Sequential vs. semantic

This is about the naming of releases in Azure DevOps (formerly known as TFS and VSTS). The default pattern of release names has been, as long as I can remember, sequential within the definition's scope: "Release 1", "Release 2", etc. That's been a minor pet peeve of mine for a while, and now we've come up with a technique to change this format to something more informative. Specifically, one can name releases with respect to the current product version, as every reasonable project team would want to.

You can't change the release name once the release is going. But the pattern for the release names is configurable, and may contain references to variables. So the idea is:

  1. Create (or pick) a variable group under Pipelines/Library
  2. Create a variable in that variable group for the current version of your product
  3. During the build, update the variable to the current version of the product
  4. In the release definition, under Variables/Variable Groups, link the variable group to the release def
  5. Under definition Options, place a $(reference) to the version variable under Release name format

This way, instead of "Release 19", you can have "Release 19 - v2.6.11".

TFS complains if $(rev:r) is not in the name format string, claims the release name won’t be unique that way. So you’d have to combine the product version and the built-in release counter in the format string.

The exact way of publishing the version number during the build might vary. If the release is being initiated by the build, then the Shared Variable Updater extension is your friend; it changes the value of a library variable to the provided string, which may be extracted from a project file, or a Win32 DLL, or a compiled .NET assembly, or what have you. Shared Variable Updater has one caveat: it needs an explicit write grant in the variable group security to update it. You need to go to the variable group security, and change the role of the “Project Collection Build Service” to Administrator.

If you build outside TFS, there is a Powershell cmdlet in the gallery module VSTeam that sets a single variable: Set-VSTeamVariableGroupVariable. It was added relatively recently, so update your VSTeam if needed.

No comments:

Post a Comment