I have a CI task in VSTS for automatic build and test and an automatic release definition for the 'Latest from build definition default branch with tags'.
The release name format is currently set to the default value $(rev:r) which just sets an increasing number that has no relation to any real version.
I'd prefer to use the version of my app as a release name either from the package.json or from the git tag created by yarn when I update the package version. Is there any way to achieve this?
You can not use git tag or package.json version for release name directly, since only part of predefined variables can be used for release name, and variables can not persist between build and release.
But you can use group variable for assistance: update group variable value with git tag or package.json version at the end of your CI build, and use the group variable as the release name. Detail steps as below:
Add variable group
In Build and Release Hub -> Library Tab -> Add Variable group (such as release name
) with a variable (such as tag
) with any initial value (such as 0
).
Change the group variable in CI build
You can add a PowerShell task to change the group variable with git tag or package.json version.
git tag --points-at HEAD
."version"
etc.Use the group variable in release
To apply the git tag or package.json version in release name, you can change your release definition as below:
Release definition -> Variables Tab -> Variable groups -> Link variable group -> select the variable group -> Options Tab -> specify the group variable tag with revision as the release name.
Now when the release is triggered, it will use the git tag or package.json version with revision for the release name.