Incorrect tag normalization in some CI environments #4401
Replies: 2 comments 1 reply
-
Would be nice if we can define this for all the supported agents, and to have the first variable to be checked |
Beta Was this translation helpful? Give feedback.
-
I think we need to first agree on a concept what the result of the normalization process should be for all agents when building from e.g. a tag. I have outlined the user expectation/scenarios in post #4291 (reply in thread) and #4212 (comment) and the current detached head behavior in post #4212 (comment). Please correct me if I'm wrong: When you set the current branch to
and change the configuration in the Does this make sense to you? |
Beta Was this translation helpful? Give feedback.
-
When triggering a CI build for a tag, some CI environments (at least GitLab CI and Azure Pipelines) will incorrectly normalize the tag name
to a local branch name. Consequently, some prerelease labels are computed incorrectly and look like this:
tags-v1-2-3-beta-1
.Current status
As mentioned by @HHobeck in #4291 (reply in thread), there is some "common deficit". The following list contains the status as far as I was able to determine:
$GITHUB_REF
GitVersion/src/GitVersion.BuildAgents/Agents/GitHubActions.cs
Lines 49 to 57 in 81425de
$BITBUCKET_BRANCH
, tag name in$BITBUCKET_TAG
GitVersion/src/GitVersion.BuildAgents/Agents/BitBucketPipelines.cs
Lines 66 to 75 in 81425de
$BUILD_SOURCEBRANCH
$CI_COMMENT_REF_NAME
I have not investigated any other CI environments.
What to do?
IBuildAgent.GetCurrentBranch()
must not returnrefs/tags/<tag>
) and align all CI agents accordingly.refs/tags/<tag>
globally inGitPreparer
.Not sure if 1) or 2) is the better approach.
Some of the reported issues have been closed by pointing out #4212. Unfortunately, it is not very clear that we are chasing a normalization issue in other CI environments.
Workaround for Azure Pipelines
The following workaround can used in Azure Pipelines wit GitVersion 6.0.5:
$GIT_BRANCH
takes precedence over$BUILD_SOURCEBRANCH
. Hence, the repository normalization will see no branch name and behave like in GitHub Actions. The workaround is quite fragile and works only in Azure Pipelines. The higher precedence of$GIT_BRANCH
is specific to Azure Pipelines.Beta Was this translation helpful? Give feedback.
All reactions