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

NPE in CliGitAPIImpl.launchCommandIn() caused by InterruptedException

XMLWordPrintable

    • 4.7.0

      We occasionaly experience failed git checkouts when an InterruptedException is raised to abort a job. This causes a job to have the result FAILURE instead of ABORTED. 

      InterruptedException doesn't have a message and the code in CliGitAPIImpl accesses the message without null check. Two example stack traces (line numbers originate from plugin build from https://github.com/jenkinsci/git-client-plugin/pull/1103, git-client:4.6.1-rc3518.4c581ea_f4c3d):

      ERROR: Checkout failed
      java.lang.NullPointerException
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871)
      at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1222)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
      at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:165)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:71)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
      at hudson.model.ResourceController.execute(ResourceController.java:101)
      at hudson.model.Executor.run(Executor.java:442)
      ERROR: Maximum checkout retry attempts reached, aborting
      Finished: FAILURE

      ERROR: Checkout failed
      java.lang.NullPointerException
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2766)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2761)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1115)
      at hudson.plugins.git.GitAPI.revParse(GitAPI.java:419)
      at hudson.plugins.git.util.DefaultBuildChooser.getCandidateRevisions(DefaultBuildChooser.java:60)
      at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1148)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1306)
      at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:165)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:71)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
      at hudson.model.ResourceController.execute(ResourceController.java:101)
      at hudson.model.Executor.run(Executor.java:442)
      ERROR: Maximum checkout retry attempts reached, aborting
      Finished: FAILURE

       

      Caused by this code section:

      } catch (GitException | InterruptedException e) {
          if (e.getMessage().contains("unsupported option \"accept-new\"")) { // causing NPE if getMessage() returns null
              listener.getLogger().println(HyperlinkNote.encodeTo("https://plugins.jenkins.io/git-client/#plugin-content-ssh-host-key-                     verification","If you are using OpenSSH < 7.6 please choose another strategy to verify ssh host key in 'Manage Jenkins' -> 'Configure Global Security' -> 'Git Host Key Verification Configuration'"));}throw e;
       

            markewaite Mark Waite
            ckullabosch Christoph Kulla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: