Skip to content

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

Closed as not planned
@madelaney

Description

@madelaney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions