Skip to content

[Bug] Unable to run with jenkins multi-branch pipeline. #3189

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

Closed
madelaney opened this issue Sep 8, 2022 · 9 comments
Closed

[Bug] Unable to run with jenkins multi-branch pipeline. #3189

madelaney opened this issue Sep 8, 2022 · 9 comments
Labels

Comments

@madelaney
Copy link

Describe the bug
When trying to use this tool with Jenkins (2.361.1), when I try to generate the next version. I get an error about LibGit2Sharp.LibGit2SharpException: ref '...' doesn't match the destination.

I've reviewed #1335 but none of the suggested work arounds worked for me.

Actual Behavior

Given the config.xml stanza. When the build runs, I get the nasty exception of:

INFO [09/08/22 15:59:18:23] Begin: Normalizing git directory for branch 'feature/jenkins/branch-nameA'
  INFO [09/08/22 15:59:18:25] One remote found (origin -> 'https://bitbucket.org/....').
  INFO [09/08/22 15:59:18:25] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [09/08/22 15:59:18:26] Updating local branch feature/jenkins/branch-nameA to match ref feature/jenkins/branch-nameA
  INFO [09/08/22 15:59:18:29] Creating local branch from remote tracking 'refs/remotes/origin/bugfix/NNNN-2617/branch-nameB'.
  INFO [09/08/22 15:59:18:30] End: Normalizing git directory for branch 'feature/jenkins/branch-nameA' (Took: 68.83ms)
  ERROR [09/08/22 15:59:18:31] An unexpected error occurred:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/bugfix/NNNN-2617/branch-nameB' doesn't match the destination
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.git_refspec_rtransform(IntPtr refSpecPtr, String name) in /_/LibGit2Sharp/Core/Proxy.cs:line 2088
   at LibGit2Sharp.Remote.FetchSpecTransformToSource(String reference) in /_/LibGit2Sharp/Remote.cs:line 138
   at LibGit2Sharp.BranchUpdater.GetUpstreamInformation(String canonicalName, String& remoteName, String& mergeBranchName) in /_/LibGit2Sharp/BranchUpdater.cs:line 188
   at LibGit2Sharp.BranchUpdater.SetUpstream(String upstreamBranchName) in /_/LibGit2Sharp/BranchUpdater.cs:line 116
   at LibGit2Sharp.BranchUpdater.set_TrackedBranch(String value) in /_/LibGit2Sharp/BranchUpdater.cs:line 53
   at GitVersion.BranchCollection.<>c__DisplayClass7_0.<UpdateTrackedBranch>g__Updater|0(BranchUpdater branchUpdater) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 43
   at LibGit2Sharp.BranchCollection.Update(Branch branch, Action`1[] actions) in /_/LibGit2Sharp/BranchCollection.cs:line 290
   at GitVersion.BranchCollection.UpdateTrackedBranch(IBranch branch, String remoteTrackingReferenceName) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 45
   at GitVersion.GitPreparer.CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(String remoteName) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 352
   at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 165
   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
   at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
  INFO [09/08/22 15:59:18:31] Attempting to show the current git graph (please include in issue): 
  INFO [09/08/22 15:59:18:31] Showing max of 100 commits
  INFO [09/08/22 15:59:18:35] * 68885a00 80 minutes ago  (HEAD -> feature/jenkins/branch-nameA origin/feature/jenkins/branch-nameA)

Steps to Reproduce

Build using Bitbucket Branch plugin for Jenkins

Context

This caused the .property file to not get created.

Your Environment

  • Jenkins UI (2.361.1)
  • Agent:
    • Ubuntu 20.04LTS
    • dotnet sdk 6.0
    • GitVersion 5.10.3
@madelaney madelaney added the bug label Sep 8, 2022
@asbjornu
Copy link
Member

asbjornu commented Sep 8, 2022

Is feature/jenkins/branch-nameA an actual branch name or is it just there as an example?

@madelaney
Copy link
Author

It's there as an example name. However, the branch is in the feature/jenkins/... directory so I wanted to show the depth of the current branch; in case it matters.

@asbjornu
Copy link
Member

asbjornu commented Sep 9, 2022

I was just wondering whether the branch names had upper and lowercase letters in them, because that is a known source of problems for mixed Windows/Linux environments.

@madelaney
Copy link
Author

madelaney commented Sep 12, 2022

We're running this on Linux (Ubuntu 20.04LTS) and the branch names are a mix of upper and loser case values. Some examples would be:

  • feature/NAN-2222/did-you-get-that-thing-i-sent
  • bugfix/NAN-1111/npm-audit-fixes
  • hotfix/0.13/NAN-999/run-it-with-link-to-run-details
  • chore/fix-a-typo
  • feature/jenkins/use-jenkins-for-build

From our developer perspective, we do have a mix of Windows & Mac OS; our build machines are migrating from Windows to Linux.

@asbjornu
Copy link
Member

Then that may definitely be the cause of this bug, as feature/NAN-2222 would be considered a different branch (and physical directory on disk) to feature/nan-2222 and feature/NaN-2222 on most Linux filesystems, while on Windows and macOS, they will be considered equal (on creation).

I would recommend that you keep all your branch names all-lowercase to avoid these x-plat file system issues.

@madelaney
Copy link
Author

I think that's fair, and I'm a snake_case in lower case fan, but being what it is this is an existing repo in which branch names are at the behest of the developer.

@asbjornu
Copy link
Member

I understand, but there's nothing we can do in GitVersion to avoid this. You will have to build some checks before running GitVersion that does some case-insensitive checks on branches before they are checked out and/or before running GitVersion to mitigate this.

@github-actions
Copy link

github-actions bot commented Mar 4, 2023

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.

@github-actions github-actions bot added the stale label Mar 4, 2023
@github-actions
Copy link

github-actions bot commented Apr 3, 2023

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2023
@arturcic arturcic removed the stale label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants