-
Notifications
You must be signed in to change notification settings - Fork 657
Description
In Azure DevOps (Server) the environment variable BUILD_SOURCEBRANCH will contain the branch of the repository that triggered the build (see documentation for Build.SourceBranch). For multi-repository builds there is no relation to the self ("main") repository, but
public override string? GetCurrentBranch(bool usingDynamicRepos) => Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH"); |
Expected Behavior
The variable should not be used in multi-repository builds, as it causes incorrect versions.
Actual Behavior
We build the dev-branch of our repo, but GitVersion thinks it should provide a version for main, as that is the branch in another repository, that triggered the build
Possible Fix
For us it would likely help to have a switch to disable the AzurePipelines-handling. It may be possible to use System.PullRequest.SourceBranch/System.PullRequest.TargetBranch when set, but even then GitVersion could be called for another repo/sub-module
Steps to Reproduce
- Set-up a multi-repository build in Azure DevOps (Server) -> https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops
- Define a trigger on one of the other repositories on at leas one branch named different from the default-branch of the repository containing the build-definition
- Commit to the other repository into the branch you defined the trigger for
- A build will run and
BUILD_SOURCEBRANCH
is set to the name of the branch in the other repository
Context
We use GitVersion to version our documentation and want to update the development-docs whenever a commit is pushed. The branch in the docs-repo is dev, while the branch-name in other repos might be master. In this case a non-pre-release-version is generated
Your Environment
Azure DevOps Server 2020 Update 1.2