-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] BUILD_SOURCEBRANCH is assumed to be relevant #3316
Comments
Following https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#repository-details you would need to access A sample addition to the build YAML might be: variables:
# self-ref to be able to use instead of Build.SourceBranch in multi-repository-builds
- name: 'repositories.self.ref'
value: $[ resources.repositories['self'].ref ] which is by default then available as the environment-variable |
I would like a fix that allows both
I would guess, that the second part of the is the one solving the common use-case, but the first allows to implement your scenario without wondering how you can remove all relevant environment-variables for the step involving GitVersion. I don't currently see a solution were everything just works out-of-the-box. It might thus be a good idea to check, if |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. |
This is still troubling our builds |
Is anyone planning on looking into it? We have a separate repo for all our YAMLs, so it's impossible to do a manual pipeline build with this bug, since it will always take the branch of the YAML itself, and not the repo which requires the versioning. |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. |
Not sure I will have time to fix this, but it's still relevant :( |
I found a workaround that seems to work on CI builds, and on manual runs.
|
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. |
Hi there. I'm not sure if this is a bug or an improvement issue. Anyway I see that the behavior is conflicting with the feature of multi-repository build in Azure DevOps. The BUILD_SOURCEBRANCH variable like you mentioned is used to determine the current branch and is highly related to AzurDevOps. Might it be an idea to us an arbitrary environment variable with the name e.g. public override string? GetCurrentBranch(bool usingDynamicRepos)
=> Environment.GetEnvironmentVariable("GIT_BRANCH")
?? Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH"); @arturcic what do you think? Regards |
@HHobeck,
I think, however, that it is a good variable for us to default to, since affaict, its semantics would be the same as its current implementation. |
I think there was a draft PR @asbjornu was working on related to the |
🎉 This issue has been resolved in version 6.0.0-beta.6 🎉 Your GitReleaseManager bot 📦🚀 |
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
GitVersion/src/GitVersion.Core/BuildAgents/AzurePipelines.cs
Line 24 in 9623cc4
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
BUILD_SOURCEBRANCH
is set to the name of the branch in the other repositoryContext
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
The text was updated successfully, but these errors were encountered: