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

Lightweight checkout gives NPE

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      git plugin 4.4.0

      Description

      Jenkins 2.164.3 with Git Plugin 3.9.3

      With the most basic Pipeline job from SCM with "Lightweight checkout" checked, the following NPE trace is the total job output.

      Unchecking "Lightweight checkout" solves the immediate NPE issue and the job completes.

      Started by user <redacted>java.lang.NullPointerException
       at jenkins.plugins.git.GitSCMFileSystem$1.invoke(GitSCMFileSystem.java:117)
       at jenkins.plugins.git.GitSCMFileSystem$1.invoke(GitSCMFileSystem.java:114)
       at jenkins.plugins.git.GitSCMFileSystem$3.invoke(GitSCMFileSystem.java:193)
       at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29)
       at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:72)
       at jenkins.plugins.git.GitSCMFileSystem.invoke(GitSCMFileSystem.java:189)
       at jenkins.plugins.git.GitSCMFileSystem.<init>(GitSCMFileSystem.java:114)
       at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:353)
       at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:198)
       at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)
       at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:108)
       at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
       at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:293)
       at hudson.model.ResourceController.execute(ResourceController.java:97)
       at hudson.model.Executor.run(Executor.java:429)
      Finished: FAILURE
      

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          Thanks Sven Hickstein. It seems counterintuitive to me to use a wildcard for a Pipeline job branch name. That will cause the specific Pipeline job to switch between branches as changes arrive on the individual branches. That creates a changelog in the job which is difficult to understand and leads to the JENKINS-19022 XML bloat problem. The multibranch Pipeline job type is designed to automatically create and destroy jobs for each branch in a repository.

          Is there a use case that I've missed for wildcard branch names with a Pipeline job?

          Show
          markewaite Mark Waite added a comment - Thanks Sven Hickstein . It seems counterintuitive to me to use a wildcard for a Pipeline job branch name. That will cause the specific Pipeline job to switch between branches as changes arrive on the individual branches. That creates a changelog in the job which is difficult to understand and leads to the JENKINS-19022 XML bloat problem. The multibranch Pipeline job type is designed to automatically create and destroy jobs for each branch in a repository. Is there a use case that I've missed for wildcard branch names with a Pipeline job?
          Hide
          hickstein Sven Hickstein added a comment - - edited

          That's right. It is very counterintuitive. But for people that are not able to use Multibranch Pipelines (huge git repositories, long build times and seperate workspaces for every branch does not work very well) this is the only option. Thanks for pointing me to the issue. That is one problem we are currently facing.

          Nevertheless, throwing a NullPointerException is not very intuitive either. A human readable error message (or just a Fallback to heavyweight checkout) might be a better option in my opinion.

           

          EDIT: We use it in conjunction with Bitbucket Server and the "Webhook to Jenkins for Bitbucket Server" Plugin. We can get a deterministic checkout of the related Jenkinsfile this way.

          Show
          hickstein Sven Hickstein added a comment - - edited That's right. It is very counterintuitive. But for people that are not able to use Multibranch Pipelines (huge git repositories, long build times and seperate workspaces for every branch does not work very well) this is the only option. Thanks for pointing me to the issue. That is one problem we are currently facing. Nevertheless, throwing a NullPointerException is not very intuitive either. A human readable error message (or just a Fallback to heavyweight checkout) might be a better option in my opinion.   EDIT: We use it in conjunction with Bitbucket Server and the "Webhook to Jenkins for Bitbucket Server" Plugin. We can get a deterministic checkout of the related Jenkinsfile this way.
          Hide
          markewaite Mark Waite added a comment -

          Thanks! I agree wholeheartedly that it is a bug and it is much worse to throw a null pointer exception than to provide the user a clear message.

          Show
          markewaite Mark Waite added a comment - Thanks! I agree wholeheartedly that it is a bug and it is much worse to throw a null pointer exception than to provide the user a clear message.
          Hide
          markewaite Mark Waite added a comment -

          See https://github.com/jenkinsci/git-plugin/pull/914 for the pull request that resolves it.

          Show
          markewaite Mark Waite added a comment - See https://github.com/jenkinsci/git-plugin/pull/914 for the pull request that resolves it.
          Hide
          markewaite Mark Waite added a comment -

          The fix prevents the lightweight checkout by declaring that lightweight checkout does not support a branch named '*'. That is correct, since lightweight checkout uses GitSCMFileSystem and GitSCMFileSystem needs an unambiguous commit.

          Show
          markewaite Mark Waite added a comment - The fix prevents the lightweight checkout by declaring that lightweight checkout does not support a branch named '*'. That is correct, since lightweight checkout uses GitSCMFileSystem and GitSCMFileSystem needs an unambiguous commit.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jblaine Jeff Blaine
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: