SolvedGitVersion Version 5.2.0 broken in Azure DevOps
✔️Accepted Answer
Ok, so it looks like the task has to change to
# Compute the semantic version of the assemblies/image
- task: UseGitVersion@5
displayName: 'GitVersion'
name: Version
inputs:
versionSpec: '5.2.0'
updateAssemblyInfo: false
useConfigFile: true
configFilePath: $(gitVersionConfig)
and then the subsequent tasks have to reference the step name as well as the variable, i.e.
# Update the reported build number to include semantic version and the numeric build id
- bash: |
echo "##vso[build.updatebuildnumber]$(Version.GitVersion.NugetVersionV2)-$(Build.BuildId)"
displayName: 'Update build number'
I see the value in the change in that the variables are now scoped, but can I just point out the irony of releasing a breaking change without obeying SemVer and increasing the version to 6.0,0 ;-)
Other Answers:
Looks like the "bug" is related to this change #2012 to allow variables to be shared across the pipeline.
Not knowing how any of this works, can variables be exposed within the same job without the prefix and outside of the job with the prefix by returning multiple items at
GitVersion/src/GitVersionCore/BuildServers/AzurePipelines.cs
Lines 20 to 26 in cfff762
by changing it to be like so?
public override string[] GenerateSetParameterMessage(string name, string value)
{
return new[]
{
$"##vso[task.setvariable variable=GitVersion.{name}]{value}",
$"##vso[task.setvariable variable=GitVersion.{name};isOutput=true]{value}"
};
}
@PNI-GS here's a summary of the marketplace tasks based on the discussion above.
Task | Remarks |
---|---|
GitVersion |
DEPRECIATED. DO NOT USE. |
UseGitVersion |
Temporary workaround/replacement for GitVersion . |
GitTools |
Will eventually replace UseGitVersion . Currently in preview version. |
Our team is currently using UseGitVersion
. We will switch to GitTools
when a stable version of it is released.
My build pipeline didn't work this morning and I noticed that GitVersion 5.2.0 was picked up, it appears that the variable setting is not being propagated between tasks as my script to assign the DevOps BuildId, can't find $(GitVersion.NuGetVersionV2), although it does seem to be assigned according to the logs...
Only differential I can find it GitVersion version
5.2.0 Build logs
GitVersion Task
Assignment Task
5.1.3 Build logs
GitVersion Task
Assignment Task