GitTools / GitVersion

From git log to SemVer in no time
https://gitversion.net/docs/
MIT License
2.87k stars 654 forks source link

[ISSUE]: GitLab CI tag pipelines result in an incorrect version #4186

Closed AlphaYankee closed 2 months ago

AlphaYankee commented 2 months ago

Prerequisites

GitVersion package

GitVersion.Tool

GitVersion version

6.0.2

Operating system

Linux

What are you seeing?

When running a tag pipeline, the tag is incorrectly detected as a branch. GitVersion gets its branch name from the environment variable CI_COMMIT_REF_NAME, but this variable is set to the tag when it's running a tag pipeline.

Example:

What is expected?

A SemVer of 1.1.2 (in this example)

Steps to Reproduce

See example in the issue description. More details in the discussion #4183

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

asbjornu commented 2 months ago

Duplicate of #4015.

AlphaYankee commented 2 months ago

The two issues are basically the same, yes. But this issue is about the incorrect usage of a GitLab CI specific environment variable, the other issue is about Azure Pipelines.

It might be better if there's a universal fix, as you said. But I believe this is a quick fix and it mirrors the fix for GitHub Actions which seems to have had a very similar problem, so it might still be a good idea to apply it for now.