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

jGit NPE in getShortBranchName with */master branch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not A Defect
    • Component/s: git-client-plugin
    • Environment:
      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
    • Similar Issues:

      Description

      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)
      

        Attachments

          Activity

          Hide
          reiern70 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

          Show
          reiern70 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
          Hide
          markewaite 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?

          Show
          markewaite 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?
          Hide
          reiern70 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.

          Show
          reiern70 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.
          Hide
          markewaite Mark Waite added a comment -

          Problem is in JGit, not in the plugin code.

          Show
          markewaite Mark Waite added a comment - Problem is in JGit, not in the plugin code.
          Hide
          reiern70 Ernesto Reinaldo Barreiro added a comment -

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

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

            People

            Assignee:
            ndeloof Nicolas De Loof
            Reporter:
            pessoft Peter KolĂ­nek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: