Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-20258

Git plugin with checkout to subdir and prune stale branches fails all builds

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • Jenkins 1.509.4, Git 2.0, Git client 1.4.5, Windows and Linux, AMD64 and x86

      I configured a job with the git 2.0 plugin to checkout to a specific subdirectory and to prune stale branches. That pair of configuration settings cause the initial git operations to fail with both git command line and jgit implementations.

      The stack trace for the command line implementation is:

      Started by user anonymous
      Building remotely on alan-pc in workspace C:\J\workspace\git-multi-subdir-prune
      Pruning obsolete local branches
      FATAL: Command "config --get remote.origin.url" returned status code 1:
      stdout: 
      stderr: 
      hudson.plugins.git.GitException: Command "config --get remote.origin.url" returned status code 1:
      stdout: 
      stderr: 
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:940)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:921)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:865)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:875)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteUrl(CliGitAPIImpl.java:603)
      	at hudson.plugins.git.GitAPI.getRemoteUrl(GitAPI.java:61)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.prune(CliGitAPIImpl.java:393)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at hudson.remoting.Engine$1$1.run(Engine.java:63)
      	at java.lang.Thread.run(Unknown Source)
      

      The stack trace for the jgit implementation is:

      Started by an SCM change
      Started by user anonymous
      Building remotely on waite2011 in workspace D:\J\workspace\git-multi-jgit-subdir-prune
      Pruning obsolete local branches
      FATAL: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
      hudson.plugins.git.GitException: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:869)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at hudson.remoting.Engine$1$1.run(Engine.java:63)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
      	at org.eclipse.jgit.transport.URIish.<init>(URIish.java:205)
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.listRemoteBranches(JGitAPIImpl.java:879)
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:857)
      	... 16 more
      

          [JENKINS-20258] Git plugin with checkout to subdir and prune stale branches fails all builds

          Mark Waite added a comment -

          Incorrectly reopened, since the fix is on the source code. Can't be fully closed yet, since the fix has not yet been delivered in a release of the Git plugin.

          Mark Waite added a comment - Incorrectly reopened, since the fix is on the source code. Can't be fully closed yet, since the fix has not yet been delivered in a release of the Git plugin.

          Oh, you are so right, I completely missed those changes. Sorry about the mess.

          Henrique Rodrigues added a comment - Oh, you are so right, I completely missed those changes. Sorry about the mess.

          Mark Waite added a comment - - edited

          Git client plugin 1.5.0 was intended to fix this (based on the submission ba2ab8934), but it still fails.

          Steps I used to duplicate the problem with Git client plugin 1.5.0:

          1. Create a new job (I named mine git-jgit-specific-subdir-prune)
          2. Configure git repo URL https://github.com/MarkEWaite/check_git.git
          3. Use jgit as the implementation rather than the default
          4. Add behavior to checkout to a local subdirectory
          5. Add behavior to prune stale remote tracking branches
          6. Save the job and run it

          Stack trace looks like:

          Building on master in workspace /var/lib/jenkins/jobs/git-jgit-specific-subdir-prune-simple/workspace
          Pruning obsolete local branches
          FATAL: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
          hudson.plugins.git.GitException: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
          	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:913)
          	at hudson.plugins.git.extensions.impl.PruneStaleBranch.beforeCheckout(PruneStaleBranch.java:31)
          	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:858)
          	at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
          	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
          	at hudson.model.Run.execute(Run.java:1665)
          	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          	at hudson.model.ResourceController.execute(ResourceController.java:88)
          	at hudson.model.Executor.run(Executor.java:246)
          Caused by: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null
          	at org.eclipse.jgit.transport.URIish.<init>(URIish.java:205)
          	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.listRemoteBranches(JGitAPIImpl.java:923)
          	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:901)
          	... 10 more
          

          Mark Waite added a comment - - edited Git client plugin 1.5.0 was intended to fix this (based on the submission ba2ab8934), but it still fails. Steps I used to duplicate the problem with Git client plugin 1.5.0: Create a new job (I named mine git-jgit-specific-subdir-prune) Configure git repo URL https://github.com/MarkEWaite/check_git.git Use jgit as the implementation rather than the default Add behavior to checkout to a local subdirectory Add behavior to prune stale remote tracking branches Save the job and run it Stack trace looks like: Building on master in workspace /var/lib/jenkins/jobs/git-jgit-specific-subdir-prune-simple/workspace Pruning obsolete local branches FATAL: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null hudson.plugins.git.GitException: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:913) at hudson.plugins.git.extensions.impl.PruneStaleBranch.beforeCheckout(PruneStaleBranch.java:31) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:858) at hudson.model.AbstractProject.checkout(AbstractProject.java:1411) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557) at hudson.model.Run.execute(Run.java:1665) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:246) Caused by: java.net.URISyntaxException: Cannot parse Git URI-ish: The uri was empty or null at org.eclipse.jgit.transport.URIish.<init>(URIish.java:205) at org.jenkinsci.plugins.gitclient.JGitAPIImpl.listRemoteBranches(JGitAPIImpl.java:923) at org.jenkinsci.plugins.gitclient.JGitAPIImpl.prune(JGitAPIImpl.java:901) ... 10 more

          Mark Waite added a comment - - edited

          This is fixed for the command line implementation in git-client-plugin 1.6.2 and git-plugin 2.0.1.

          It is not fixed in the JGit implementation but it now reports a much clearer error message:

          JGit don't (yet) support pruning during fetch
          
          Started by user anonymous
          Building remotely on jessie64a in workspace /var/lib/jenkins/wheezy64b-slave/workspace/JENKINS-20258-checkout-to-subdir-and-prune-jgit
          Cloning the remote Git repository
          remote: Counting objects
          remote: Compressing objects
          Receiving objects
          Resolving deltas
          Updating references
          Pruning obsolete local branches
          FATAL: Failed to fetch from git://wheezy64b/git/mwaite/bin.git
          hudson.plugins.git.GitException: Failed to fetch from git://wheezy64b/git/mwaite/bin.git
          	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:625)
          	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:847)
          	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:872)
          	at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
          	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
          	at hudson.model.Run.execute(Run.java:1665)
          	at hudson.matrix.MatrixBuild.run(MatrixBuild.java:304)
          	at hudson.model.ResourceController.execute(ResourceController.java:88)
          	at hudson.model.Executor.run(Executor.java:246)
          	at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)
          Caused by: hudson.plugins.git.GitException: java.lang.reflect.InvocationTargetException
          	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:156)
          	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          	at hudson.remoting.Request$2.run(Request.java:326)
          	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          	at java.lang.Thread.run(Thread.java:744)
          Caused by: java.lang.reflect.InvocationTargetException
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:606)
          	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$Invocation.replay(RemoteGitImpl.java:101)
          	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
          	... 9 more
          Caused by: java.lang.UnsupportedOperationException: JGit don't (yet) support pruning during fetch
          	at org.jenkinsci.plugins.gitclient.JGitAPIImpl$1.prune(JGitAPIImpl.java:375)
          	... 15 more
          

          Mark Waite added a comment - - edited This is fixed for the command line implementation in git-client-plugin 1.6.2 and git-plugin 2.0.1. It is not fixed in the JGit implementation but it now reports a much clearer error message: JGit don't (yet) support pruning during fetch Started by user anonymous Building remotely on jessie64a in workspace /var/lib/jenkins/wheezy64b-slave/workspace/JENKINS-20258-checkout-to-subdir-and-prune-jgit Cloning the remote Git repository remote: Counting objects remote: Compressing objects Receiving objects Resolving deltas Updating references Pruning obsolete local branches FATAL: Failed to fetch from git://wheezy64b/git/mwaite/bin.git hudson.plugins.git.GitException: Failed to fetch from git://wheezy64b/git/mwaite/bin.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:625) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:847) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:872) at hudson.model.AbstractProject.checkout(AbstractProject.java:1411) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557) at hudson.model.Run.execute(Run.java:1665) at hudson.matrix.MatrixBuild.run(MatrixBuild.java:304) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:246) at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66) Caused by: hudson.plugins.git.GitException: java.lang.reflect.InvocationTargetException at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:156) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:326) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$Invocation.replay(RemoteGitImpl.java:101) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151) ... 9 more Caused by: java.lang.UnsupportedOperationException: JGit don't (yet) support pruning during fetch at org.jenkinsci.plugins.gitclient.JGitAPIImpl$1.prune(JGitAPIImpl.java:375) ... 15 more

          Mark Waite added a comment -

          No fix intended for JGit implementation. Works in command line and clearly states that it is not implemented in JGit.

          Mark Waite added a comment - No fix intended for JGit implementation. Works in command line and clearly states that it is not implemented in JGit.

          pmv added a comment -

          It looks like JGit 3.3 can now do pruning? "Support fetch.prune and remote.<name>.prune to set prune mode when fetching" - https://wiki.eclipse.org/JGit/New_and_Noteworthy/3.3

          Should a new ticket be opened to get this fix applied to the JGit implementation?

          pmv added a comment - It looks like JGit 3.3 can now do pruning? "Support fetch.prune and remote.<name>.prune to set prune mode when fetching" - https://wiki.eclipse.org/JGit/New_and_Noteworthy/3.3 Should a new ticket be opened to get this fix applied to the JGit implementation?

          Mark Waite added a comment -

          Code already exists in the JGit implementation to evaluate the prune implementation that was included in JGit 3.3. Unfortunately, the JGit 3.3 prune removes more branches than command line git. Since that would give incompatible behavior between CliGit and JGit, and CliGit is the reference implementation, the JGit prune at fetch can't be enabled.

          Refer to this submission which attempted to use JGit prune with JGit 3.5.2 and confirmed that it is still pruning too many branches.

          Mark Waite added a comment - Code already exists in the JGit implementation to evaluate the prune implementation that was included in JGit 3.3. Unfortunately, the JGit 3.3 prune removes more branches than command line git. Since that would give incompatible behavior between CliGit and JGit, and CliGit is the reference implementation, the JGit prune at fetch can't be enabled. Refer to this submission which attempted to use JGit prune with JGit 3.5.2 and confirmed that it is still pruning too many branches.

          pmv added a comment -

          Thanks for the update. Is there an open ticket I can watch for this feature (rather than commenting on this old one)?

          Personally I'd be in favor of a "use this feature with JGit at your own risk" message rather than not supporting prune at all, but I understand your logic.

          pmv added a comment - Thanks for the update. Is there an open ticket I can watch for this feature (rather than commenting on this old one)? Personally I'd be in favor of a "use this feature with JGit at your own risk" message rather than not supporting prune at all, but I understand your logic.

          Mark Waite added a comment -

          I've been unwilling to accept incompatible behavior between CliGit and JGit. Use at your own risk seems too risky for a plugin used in over 50 000 installations.

          You're welcome to open a separate bug report / enhancement request to track it. That seems like it will make it easier to track, and easier to report the problem to the upstream JGit process.

          Mark Waite added a comment - I've been unwilling to accept incompatible behavior between CliGit and JGit. Use at your own risk seems too risky for a plugin used in over 50 000 installations. You're welcome to open a separate bug report / enhancement request to track it. That seems like it will make it easier to track, and easier to report the problem to the upstream JGit process.

          pmv added a comment -

          Created and linked JENKINS-26197.

          pmv added a comment - Created and linked JENKINS-26197 .

            Unassigned Unassigned
            markewaite Mark Waite
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: