-
Bug
-
Resolution: Fixed
-
Minor
-
None
When attempting a pre-build merge with JGit a null pointer exception is reported. The stack trace is:
java.lang.NullPointerException at hudson.plugins.git.util.GitUtils.getRevisionForSHA1(GitUtils.java:166) at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:119) at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1058) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1151) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:120) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:90) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:77) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)
Refer to my jenkins-bugs test repository for the details.
The failure is specific to the JGit implementation. It was not visible in the command line git implementation.
- links to
GitAPITestCase is a JUnit 3 test class that provides test implementations that are used in 3 different tests (CliGitAPIImplTest, JGitAPIImplTest, and JGitApacheAPIImplTest). We're working to replace that combination of 4 test classes with JUnit 4 tests that are based on GitClientTest.
I'd suggest that you create a separate test class based on GitClientTest for this specific case. The existing git client plugin test classes feel too large to me. You may even want to make the new test specific to JGit, without the overhead and complexity of a parameterized test.
Since the existing tests did not detect this problem, I think adding a new test (and even a new test class) is quite reasonable.