When running in GitLab CI SonarQube uses a mechanism of its
own to determine the “correct” branch name.
This is triggered when:
property sonar.branch.name is empty or not given at all and
the environment variable GITLAB_CI is true.
Then SonarQube will set sonar.branch.name to CI_COMMIT_REF_NAME.
In the case of a tag build in GitLab this unfortunately has the effect
that the version is set on a branch called CI_COMMIT_REF_NAME because then CI_COMMIT_REF_NAME is identical to CI_COMMIT_TAG.
These branches are not kept in general so:
the version is not visible on the “MAIN BRANCH” and at the same time
“new code measures” are reported wrongly as well as they are calculated as issues since the last version on the same branch.