[JIRA] (JENKINS-57587) Lightweight checkout gives NPE

2 views
Skip to first unread message

jblaine@kickflop.net (JIRA)

unread,
May 21, 2019, 3:00:03 PM5/21/19
to jenkinsc...@googlegroups.com
Jeff Blaine created an issue
 
Jenkins / Bug JENKINS-57587
Lightweight checkout gives NPE
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2019-05-21 18:59
Labels: NPE
Priority: Minor Minor
Reporter: Jeff Blaine

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

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 4:51:34 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 4:51:35 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-57587
 
Re: Lightweight checkout gives NPE

I am unable to duplicate the problem you're describing.

My attempt to duplicate the problem on Jenkins 2.164.3 with git plugin 3.10.0:

  1. Create JENKINS-57587 branch in my jenkins-bugs repository
  2. Create a JENKINS-57587 pipeline job
  3. Configure job to get Pipeline script from SCM using Git
  4. Configure git repository https://github.com/MarkEWaite/jenkins-bugs to checkout branch JENKINS-57587
  5. Leave Lightweight checkout enabled in the job definition
  6. Save the job definition
  7. Build now

Can you provide more details on your configuration and how it is different from the configuration I tried?

My test job uses a pipeline shared library.

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 4:52:01 PM5/21/19
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 4:53:01 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
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.

{
noformat {
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

{noformat
} }

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 4:53:03 PM5/21/19
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 5:07:02 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-57587
I am unable to duplicate the problem you're describing.

My attempt to duplicate the problem on Jenkins 2.164.3 with git plugin 3.10.0:
# Create [JENKINS-57587 branch|https://github.com/MarkEWaite/jenkins-bugs/blob/JENKINS-57587/README.md] in my jenkins-bugs repository
# Create a
[pipeline job|https://github.com/MarkEWaite/docker-lfs/blob/940d3bd3a4c27aa56d4d1a9f1efd841927ba095b/ref/jobs/Bugs-Individual/jobs/ JENKINS-57587 pipeline job -NPE-on-lightweight-checkout/config.xml#L1]
# Configure job to get Pipeline script from SCM using Git
# Configure git repository https://github.com/MarkEWaite/jenkins-bugs to checkout branch JENKINS-57587
# Leave {{Lightweight checkout}} enabled in the job definition
# Save the job definition
# Build now


Can you provide more details on your configuration and how it is different from the configuration I tried?

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 5:07:03 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-57587
I am unable to duplicate the problem you're describing.

My attempt to duplicate the problem on Jenkins 2.164.3 with git plugin 3.10.0:
# Create [JENKINS-57587 branch|https://github.com/MarkEWaite/jenkins-bugs/blob/JENKINS-57587/README.md] in my jenkins-bugs repository

# Configure job to get Pipeline script from SCM using Git
# Configure git repository https://github.com/MarkEWaite/jenkins-bugs to checkout branch JENKINS-57587
# Leave {{Lightweight checkout}} enabled in the job definition
# Save the job definition
# Build now

Can you provide more details on your configuration and how it is different from the configuration I tried?

My [test job|https://github.com/MarkEWaite/docker-lfs/blob/940d3bd3a4c27aa56d4d1a9f1efd841927ba095b/ref/jobs/Bugs-Individual/jobs/JENKINS-57587-NPE-on-lightweight-checkout/config.xml#L1] uses a [pipeline shared library|https://github.com/MarkEWaite/jenkins-pipeline-utils].

mark.earl.waite@gmail.com (JIRA)

unread,
May 21, 2019, 5:08:02 PM5/21/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-57587
I am unable to duplicate the problem you're describing.

My attempt to duplicate the problem on Jenkins 2.164.3 with git plugin 3.10.0 on Debian 9 with JDK 8 :

# Create [JENKINS-57587 branch|https://github.com/MarkEWaite/jenkins-bugs/blob/JENKINS-57587/README.md] in my jenkins-bugs repository
# Create a [pipeline job|https://github.com/MarkEWaite/docker-lfs/blob/940d3bd3a4c27aa56d4d1a9f1efd841927ba095b/ref/jobs/Bugs-Individual/jobs/JENKINS-57587-NPE-on-lightweight-checkout/config.xml#L1]
# Configure job to get Pipeline script from SCM using Git
# Configure git repository https://github.com/MarkEWaite/jenkins-bugs to checkout branch JENKINS-57587
# Leave {{Lightweight checkout}} enabled in the job definition
# Save the job definition
# Build now

Can you provide more details on your configuration and how it is different from the configuration I tried?

My [test job|https://github.com/MarkEWaite/docker-lfs/blob/940d3bd3a4c27aa56d4d1a9f1efd841927ba095b/ref/jobs/Bugs-Individual/jobs/JENKINS-57587-NPE-on-lightweight-checkout/config.xml#L1] uses a [pipeline shared library|https://github.com/MarkEWaite/jenkins-pipeline-utils].

mark.earl.waite@gmail.com (JIRA)

unread,
May 22, 2019, 9:56:01 AM5/22/19
to jenkinsc...@googlegroups.com


The [source code at the failing location|https://github.com/jenkinsci/git-plugin/blob/0e5a390cafaaa59f9b3cb11cf67b6cfcb14fbe53/src/main/java/jenkins/plugins/git/GitSCMFileSystem.java#L117] indicates that either the repository was null or the returned ObjectId was null.  Neither are expected conditions.

mark.earl.waite@gmail.com (JIRA)

unread,
May 26, 2019, 9:14:02 PM5/26/19
to jenkinsc...@googlegroups.com

jblaine@kickflop.net (JIRA)

unread,
May 28, 2019, 9:44:02 AM5/28/19
to jenkinsc...@googlegroups.com

Mark, I will try to reproduce with Git Plugin 3.10.0. That wasn't available yet when we saw this failure. If it still fails, I will provide more details about our config and the job config but the latter test case is pretty simplistic.

mark.earl.waite@gmail.com (JIRA)

unread,
May 28, 2019, 10:34:02 AM5/28/19
to jenkinsc...@googlegroups.com

Since 3.10.0 doesn't change anything in this area compared to 3.9.3, I assume you will still be able to duplicate it.

If you can duplicate it, please upload the config.xml of the job definition so that I can compare it to my test job. Also, please describe any areas where the steps you took were different than the steps I took.

jblaine@kickflop.net (JIRA)

unread,
May 28, 2019, 10:37:01 AM5/28/19
to jenkinsc...@googlegroups.com

Yes, I can still reproduce the same NPE with "Lightweight checkout" enabled using Git Plugin 3.10.0.

  1. Our job definition uses a repo URL of the format ssh://g...@bitbucket.our.org/~username/repo.git
  2. Our job definition specifies the appropriate Jenkins creds for that URL

Maybe that will lead us somewhere?

mark.earl.waite@gmail.com (JIRA)

unread,
May 28, 2019, 11:45:01 AM5/28/19
to jenkinsc...@googlegroups.com

I used an ssh protocol Bitbucket URL (g...@bitbucket.org:markewaite/jenkins-bugs.git) to clone the Pipeline with git plugin 3.10.0 and git plugin 4.0 pre-release without seeing an NPE. I also used ssh://g...@bitbucket.org/markewaite/jenkins-bugs.git to check with git plugin 3.10.0. I'm using an ed235519 ssh credential with the Bitbucket repository. Unfortunately, I still can't duplicate the problem you're seeing.

mark.earl.waite@gmail.com (JIRA)

unread,
Jun 30, 2019, 11:57:02 AM6/30/19
to jenkinsc...@googlegroups.com

jblaine@kickflop.net (JIRA)

unread,
Aug 2, 2019, 9:28:01 AM8/2/19
to jenkinsc...@googlegroups.com

Well isn't that fun... I came back finally to provide you with more info and ... can no longer reproduce this. I guess this can be closed. Thanks for assisting and trying to solve this with me, Mark.

mark.earl.waite@gmail.com (JIRA)

unread,
Aug 2, 2019, 9:42:02 AM8/2/19
to jenkinsc...@googlegroups.com
Mark Waite updated Bug JENKINS-57587
 

Thanks for checking again. If you find a way to duplicate it, please reopen it with the details.

Change By: Mark Waite
Status: Open Fixed but Unreleased
Resolution: Cannot Reproduce

mark.earl.waite@gmail.com (JIRA)

unread,
Aug 2, 2019, 9:42:03 AM8/2/19
to jenkinsc...@googlegroups.com
Change By: Mark Waite
Status: Fixed but Unreleased Closed

sven.hickstein@draeger.com (JIRA)

unread,
Dec 20, 2019, 7:06:03 AM12/20/19
to jenkinsc...@googlegroups.com
Sven Hickstein reopened an issue
 

I was able to reproduce the issue.

Just use a star "*" as the branch pattern. This will result in a NullPointerException.
Maybe you should add this to the "not supported" checks in the GitSCMFileSystem class:

https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitSCMFileSystem.java#L255 

And if you're on it:
If you leave the branch field empty or use the default "**" the plugin will complain about an invalid refspec:

java.lang.IllegalArgumentException: Invalid refspec refs/heads/**
 at org.eclipse.jgit.transport.RefSpec.checkValid(RefSpec.java:540)
 at org.eclipse.jgit.transport.RefSpec.<init>(RefSpec.java:192)
 at org.eclipse.jgit.transport.RefSpec.<init>(RefSpec.java:227)
 at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:345)
 at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
 at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
 at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115)
 at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
 at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
 at hudson.model.ResourceController.execute(ResourceController.java:97)
 at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

Maybe this should be added to the not supported cases too.

Change By: Sven Hickstein
Resolution: Cannot Reproduce
Status: Closed Reopened
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 20, 2019, 7:14:03 AM12/20/19
to jenkinsc...@googlegroups.com

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?

sven.hickstein@draeger.com (JIRA)

unread,
Dec 20, 2019, 7:24:02 AM12/20/19
to jenkinsc...@googlegroups.com

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.

sven.hickstein@draeger.com (JIRA)

unread,
Dec 20, 2019, 7:26:02 AM12/20/19
to jenkinsc...@googlegroups.com
Sven Hickstein edited a comment on Bug JENKINS-57587
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.

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 20, 2019, 8:15:03 AM12/20/19
to jenkinsc...@googlegroups.com

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.

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 20, 2019, 8:21:02 AM12/20/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages