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

jGit NPE in getShortBranchName with */master branch

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • git-client-plugin
    • Jenkins ver. 1.532.3 Master on RHEL x64
      Jenkins Slave node via JNLP start on Windows 7 x64
      Jenkins GIT client plugin 1.8.0
      Jenkins GIT plugin 2.2.1

      Hi,

      jGit NPE during check out of branch name set as */master

      Fetching changes from the remote Git repository
      Checking out Revision 5fb16a411385dc6496705703081c3e1c3f830d13 (origin/master)
      FATAL: null
      java.lang.NullPointerException
              at org.eclipse.jgit.api.CheckoutCommand.getShortBranchName(CheckoutCommand.java:323)
              at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:223)
              at org.jenkinsci.plugins.gitclient.JGitAPIImpl.doCheckout(JGitAPIImpl.java:215)
              at org.jenkinsci.plugins.gitclient.JGitAPIImpl.access$100(JGitAPIImpl.java:97)
              at org.jenkinsci.plugins.gitclient.JGitAPIImpl$1.execute(JGitAPIImpl.java:200)
              at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
              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$Sync.innerRun(FutureTask.java:334)
              at java.util.concurrent.FutureTask.run(FutureTask.java:166)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at hudson.remoting.Engine$1$1.run(Engine.java:63)
              at java.lang.Thread.run(Thread.java:722)
      

          [JENKINS-22732] jGit NPE in getShortBranchName with */master branch

          Mark Waite added a comment -

          Based on the JGit 3.3.1 source code at that line, it appears the repository cloned in that directory cannot resolve a reference named "HEAD". I believe that might indicate the repository is corrupt or is incomplete in some way. Can you check if the contents of the .git directory appear reasonable to you?

          You could also try switching to the command line git implementation to see if it provides any other hints about the problem.

          Mark Waite added a comment - Based on the JGit 3.3.1 source code at that line, it appears the repository cloned in that directory cannot resolve a reference named "HEAD". I believe that might indicate the repository is corrupt or is incomplete in some way. Can you check if the contents of the .git directory appear reasonable to you? You could also try switching to the command line git implementation to see if it provides any other hints about the problem.

          Mark Waite added a comment -

          Since the null pointer exception is inside the JGit library, and is at a location which hints that the repository may be incomplete or corrupt, and since the original submitter has not responded to a request for more information in 7 days, I'm closing this bug as "Cannot Reproduce".

          Mark Waite added a comment - Since the null pointer exception is inside the JGit library, and is at a location which hints that the repository may be incomplete or corrupt, and since the original submitter has not responded to a request for more information in 7 days, I'm closing this bug as "Cannot Reproduce".

          Thank you for you feedback. Currently I was not able to reproduce this issue with updated environment:
          Jenkins ver. 1.554.2 Master on RHEL x64
          Jenkins Slave node via JNLP start on Windows 7 x64
          Jenkins GIT client plugin 1.9.1
          Jenkins GIT plugin 2.2.1

          Peter Kolínek added a comment - Thank you for you feedback. Currently I was not able to reproduce this issue with updated environment: Jenkins ver. 1.554.2 Master on RHEL x64 Jenkins Slave node via JNLP start on Windows 7 x64 Jenkins GIT client plugin 1.9.1 Jenkins GIT plugin 2.2.1

          Hi,

          It seems I'm having exactly this issue. I can consistently reproduce it with a project I check out form GITHUB. Do you want me to provide a maven project showcasing it?

          Ernesto Reinaldo Barreiro added a comment - Hi, It seems I'm having exactly this issue. I can consistently reproduce it with a project I check out form GITHUB. Do you want me to provide a maven project showcasing it?

          It can be easily reproduced with

          https://github.com/reiern70/core.git

          and use Git.clone to locally clone the project and check out to check any branch

          Ernesto Reinaldo Barreiro added a comment - It can be easily reproduced with https://github.com/reiern70/core.git and use Git.clone to locally clone the project and check out to check any branch

          Mark Waite added a comment -

          I'm unable to duplicate the bug based on your instructions. The steps I took:

          1. Create a new Jenkins job
          2. Use git for SCM, with jgit as the git provider
          3. Use https://github.com/reiern70/core.git as the repository.
          4. Set "Branches to build" as "*/master"
          5. Add additional behavior "Check out to specific local branch", name the branch "master"
          6. Add a build step to execute "git log -n 1"
          7. Build the job

          Those steps did not report a null pointer exception. The job completed successfully. Can you further clarify the steps you used, and if you were using the most recent version of the git-plugin and the git-client-plugin?

          Mark Waite added a comment - I'm unable to duplicate the bug based on your instructions. The steps I took: Create a new Jenkins job Use git for SCM, with jgit as the git provider Use https://github.com/reiern70/core.git as the repository. Set "Branches to build" as "*/master" Add additional behavior "Check out to specific local branch", name the branch "master" Add a build step to execute "git log -n 1" Build the job Those steps did not report a null pointer exception. The job completed successfully. Can you further clarify the steps you used, and if you were using the most recent version of the git-plugin and the git-client-plugin?

          Hi,

          I'm using

          <dependency>
          <groupId>org.eclipse.jgit</groupId>
          <artifactId>org.eclipse.jgit</artifactId>
          <version>3.4.0.201406110918-r</version>
          </dependency>

          I might be using API in a wrong way then:

          1- I use CloneCommand to pull repo from remote github
          2- I use git.checkout().setName(branchName).setCreateBranch(true)
          .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM).setStartPoint("origin/" + branchName).call();

          Now I get

          org.eclipse.jgit.api.errors.RefNotFoundException: Ref origin/core-6.5.0 can not be resolved
          at org.eclipse.jgit.api.CheckoutCommand.getStartPoint(CheckoutCommand.java:483)
          at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:216)
          at com.codersjobs.project.fetcher.git.GitProjectsFetcher.doCheckOut(GitProjectsFetcher.java:58)
          at com.codersjobs.project.fetcher.AbstractProjectsFetcher.fetch(AbstractProjectsFetcher.java:56)
          at com.codersjobs.project.fetcher.git.GitProjectsFetcherTest.testDoCheckOutBranches(GitProjectsFetcherTest.java:35)
          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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
          at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
          at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
          at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
          at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
          at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
          at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)

          So, it is not the same as before... Please, close this as it is clear that it might be me doing a wrong us of low level API.

          Ernesto Reinaldo Barreiro added a comment - Hi, I'm using <dependency> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit</artifactId> <version>3.4.0.201406110918-r</version> </dependency> I might be using API in a wrong way then: 1- I use CloneCommand to pull repo from remote github 2- I use git.checkout().setName(branchName).setCreateBranch(true) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM).setStartPoint("origin/" + branchName).call(); Now I get org.eclipse.jgit.api.errors.RefNotFoundException: Ref origin/core-6.5.0 can not be resolved at org.eclipse.jgit.api.CheckoutCommand.getStartPoint(CheckoutCommand.java:483) at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:216) at com.codersjobs.project.fetcher.git.GitProjectsFetcher.doCheckOut(GitProjectsFetcher.java:58) at com.codersjobs.project.fetcher.AbstractProjectsFetcher.fetch(AbstractProjectsFetcher.java:56) at com.codersjobs.project.fetcher.git.GitProjectsFetcherTest.testDoCheckOutBranches(GitProjectsFetcherTest.java:35) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65) So, it is not the same as before... Please, close this as it is clear that it might be me doing a wrong us of low level API.

          Mark Waite added a comment -

          Problem is in JGit, not in the plugin code.

          Mark Waite added a comment - Problem is in JGit, not in the plugin code.

          ok. Fixed with a "workaround". Thanks and apologies for the noise.

          Ernesto Reinaldo Barreiro added a comment - ok. Fixed with a "workaround". Thanks and apologies for the noise.

            ndeloof Nicolas De Loof
            pessoft Peter Kolínek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: