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

Git plugin fails to checkout master branch on remote slave

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • git-plugin

      Upgraded to version 2.0 of the Git plugin today when it was available in my plugin manager. Created an jgit Git plugin in the settings, and updated my git settings as shown in the config.xml below.

      The build fails quickly with the following error when trying to check out origin/master.

      Started by user Jonas Rabbe
      [EnvInject] - Loading node environment variables.
      Building remotely on Regular Jenkins Slave (i-1dc1d27a) in workspace /home/jenkins/workspace/radius-master
      [ssh-agent] Using credentials git (Radius repo deploy key)
      [ssh-agent] Looking for ssh-agent implementation...
      [ssh-agent]   Java/JNR ssh-agent
      [ssh-agent] Started.
      Wiping out workspace first.
      Cloning the remote Git repository
      remote: Counting objects
      remote: Compressing objects
      Receiving objects
      Resolving deltas
      Updating references
      Checking out Revision 5bd8914ecb46307249add0916b3493160c882096 (origin/master)
      FATAL: Could not checkout null
      hudson.plugins.git.GitException: Could not checkout null
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.checkout(JGitAPIImpl.java:202)
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.checkoutBranch(JGitAPIImpl.java:239)
      	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 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(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:724)
      Caused by: org.eclipse.jgit.api.errors.InvalidRefNameException: Branch name <null> is not allowed
      	at org.eclipse.jgit.api.CheckoutCommand.processOptions(CheckoutCommand.java:471)
      	at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:200)
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.checkout(JGitAPIImpl.java:187)
      	... 16 more
      

      My config.xml for the SCM part looks like this:

        <scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
          <configVersion>2</configVersion>
          <userRemoteConfigs>
            <hudson.plugins.git.UserRemoteConfig>
              <url>git@github.com:RadiusIntelligence/radius.git</url>
              <credentialsId>6893051d-565e-4a85-8c56-5d6f88f45d1a</credentialsId>
            </hudson.plugins.git.UserRemoteConfig>
          </userRemoteConfigs>
          <branches>
            <hudson.plugins.git.BranchSpec>
              <name>origin/master</name>
            </hudson.plugins.git.BranchSpec>
          </branches>
          <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
          <gitTool>jgit</gitTool>
          <submoduleCfg class="list"/>
          <extensions>
            <hudson.plugins.git.extensions.impl.WipeWorkspace/>
          </extensions>
        </scm>
      

          [JENKINS-20195] Git plugin fails to checkout master branch on remote slave

          Jonas Rabbe created issue -

          Jonas Rabbe added a comment -

          This is running against v. 1.4.4 of the Git Client Plugin, and Jenkins is version 1.534.

          Jonas Rabbe added a comment - This is running against v. 1.4.4 of the Git Client Plugin, and Jenkins is version 1.534.

          Jonas Rabbe added a comment -

          Just updated to Jenkins version 1.536, but still get same problem. The build takes place on a Jenkins slave that is dynamically started on an EC2 instance.

          Jonas Rabbe added a comment - Just updated to Jenkins version 1.536, but still get same problem. The build takes place on a Jenkins slave that is dynamically started on an EC2 instance.

          I have the same problem

          Jenkins version: 1.536
          Git plugin: 2.0

          I thought it could be fixed by using git instead of jgit, but problem occurs in both cases. I will appreciate quick fix

          Maciej Sawicki added a comment - I have the same problem Jenkins version: 1.536 Git plugin: 2.0 I thought it could be fixed by using git instead of jgit, but problem occurs in both cases. I will appreciate quick fix

          Mark Waite added a comment - - edited

          I was able to duplicate the same problem by defining a new job which uses the Git plugin without defining any credentials.

          0 - Define jgit as an available git implementation
          1 - Create a new job - I named mine "check_git"
          2 - Configure job to use Git plugin
          3 - Enter https://github.com/MarkEWaite/check_git.git as the URL for the repository
          4 - Select jgit as the git implementation
          5 - Save the job definition
          5 - Build the job that was just saved

          The job will fail with the report that it cannot checkout branch null, with the stack trace as listed in the original report.

          The same problem happens for a git protocol URL using jgit as the git implementation.

          The same problem does not happen for a git protocol URL using command line git as the git implementation.

          Mark Waite added a comment - - edited I was able to duplicate the same problem by defining a new job which uses the Git plugin without defining any credentials. 0 - Define jgit as an available git implementation 1 - Create a new job - I named mine "check_git" 2 - Configure job to use Git plugin 3 - Enter https://github.com/MarkEWaite/check_git.git as the URL for the repository 4 - Select jgit as the git implementation 5 - Save the job definition 5 - Build the job that was just saved The job will fail with the report that it cannot checkout branch null, with the stack trace as listed in the original report. The same problem happens for a git protocol URL using jgit as the git implementation. The same problem does not happen for a git protocol URL using command line git as the git implementation.

          Mark Waite added a comment -

          One possible work around is to add the extra Git behavior "Checkout to specific local branch" and give the name of a branch (like master-local). That allowed my git protocol URL repository to clone and checkout with the jgit implementation.

          Mark Waite added a comment - One possible work around is to add the extra Git behavior "Checkout to specific local branch" and give the name of a branch (like master-local). That allowed my git protocol URL repository to clone and checkout with the jgit implementation.

          Mark Waite added a comment -

          Confirmed the bug is fixed. I used the steps I listed to attempt to duplicate the bug with Git plugin 2.0 and git client plugin 1.6.0.

          Mark Waite added a comment - Confirmed the bug is fixed. I used the steps I listed to attempt to duplicate the bug with Git plugin 2.0 and git client plugin 1.6.0.
          Mark Waite made changes -
          Fix Version/s New: current [ 10162 ]
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Mark Waite added a comment -

          Verified resolved in git client plugin 1.6.0.

          Mark Waite added a comment - Verified resolved in git client plugin 1.6.0.
          Mark Waite made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            ndeloof Nicolas De Loof
            jrabbe Jonas Rabbe
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: