You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched issues to ensure it has not already been reported
GitVersion package
GitVersion.Tool
GitVersion version
6.3.0
Operating system
Linux
What are you seeing?
When I am running the Gitversion tool in my Azure pipeline I am always getting -no-branch- as prerelease label/tag on a develop branch. It is somehow related to the fact that Azure pipelines always checks out in detached head mode.
Strangely I can see in the logs that the branch was properly identified: INFO [25-05-06 16:39:55:38] Branch from build environment: refs/heads/develop
Interestingly the previously used version of the tool (5.8.1) was providing the "develop" branch configuration "label" value when running on the exact same commit. We would like to get this behaviour back.
To get "develop" as "PreReleaseLabel" since the branch name is given via env var BUILD_SOURCEBRANCH.
Steps to Reproduce
#$1 is repo name
#$2 is branch name
#$3 is commit sha1
git init
git remote add origin https://[email protected]/my-org/${1}
git sparse-checkout disable
git config gc.auto 0
git config core.longpaths true
git fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +${3}:refs/remotes/origin/${3}
git fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +${3}
git checkout --progress --force refs/remotes/origin/$3
git submodule sync --recursive
git submodule update --init --force --depth=1 --recursive
log "Unshallowing Git repository"
git fetch --unshallow --no-recurse-submodules
# These env vars are set by Azure pipelines and are used by the gitversion tool. To recognize
# that it is running in a pipeline the TF_BUILD env var is used. The tool then uses the value of BUILD_SOURCEBRANCH to determine
# the branch name.
export TF_BUILD=True
export BUILD_SOURCEBRANCH=refs/heads/$2
export BUILD_BUILDNUMBER=123456
CURR_DIR=$(pwd)
COMMON_CLI_ARGS="/nonormalize /nocache /config "${ROOT_DIR}/GitVersion.yml""
set -x
"${ROOT_DIR}/dotnet-gitversion" "$CURR_DIR" $COMMON_CLI_ARGS /output file /outputfile "${ROOT_DIR}/semver.json" /verbosity Verbose /l "${ROOT_DIR}/semver.log"
set +x
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
The text was updated successfully, but these errors were encountered:
MTomBosch
changed the title
[ISSUE]: Azure pipelines always provides -no-branch- as prerelease label although Branch is recognized
[ISSUE]: Azure pipelines always provides -no-branch- as prerelease label although branch is recognized
May 6, 2025
Prerequisites
GitVersion package
GitVersion.Tool
GitVersion version
6.3.0
Operating system
Linux
What are you seeing?
When I am running the Gitversion tool in my Azure pipeline I am always getting -no-branch- as prerelease label/tag on a develop branch. It is somehow related to the fact that Azure pipelines always checks out in detached head mode.
Strangely I can see in the logs that the branch was properly identified:
INFO [25-05-06 16:39:55:38] Branch from build environment: refs/heads/develop
Interestingly the previously used version of the tool (5.8.1) was providing the "develop" branch configuration "label" value when running on the exact same commit. We would like to get this behaviour back.
Any idea what is going wrong in my configuration?
I am pasting my config:
What is expected?
To get "develop" as "PreReleaseLabel" since the branch name is given via env var BUILD_SOURCEBRANCH.
Steps to Reproduce
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
The text was updated successfully, but these errors were encountered: