Scans fail on Windows based Jenkins slaves due to NullPointerException during the blame process

288 views
Skip to first unread message

vijkr...@gmail.com

unread,
Oct 30, 2017, 11:22:51 AM10/30/17
to SonarQube
SonarQube Server: v5.6.6 LTS
Sonar SCM Git plugin: v1.2
Base directory of scan: D:\jenkins\myworkspace\code\myproject (slightly modified to protect sensitive information)
Note: I am using a shared workspace in Jenkins. Path contains no spaces.

Error encountered:
java.lang.IllegalStateException: Unable to blame file src/com/***/**.java
	at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:128)
	at org.sonarsource.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:44)
	at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:112)
	at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:109)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at org.eclipse.jgit.treewalk.filter.PathFilter.create(PathFilter.java:77)
	at org.eclipse.jgit.blame.BlameGenerator.<init>(BlameGenerator.java:161)
	at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:203)
	at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:126)
	... 7 more

I reran the scan using the -X switch, and noticed the following error:
DEBUG    Blame file null

I saw this error occur once for EVERY file being scanned. In summary, the blame process failed for every file in the workspace, and was not specific to one or more files.

I initially thought this may be due to JGit, but on further inspection of the logs, I could see that the issue occurs on the first line of code within the org.sonarsource.scm.git.JGitBlameCommand.blame() method:
String filename = pathResolver.relativePath(gitBaseDir, inputFile.file());

The relativePath() method is returning a null value, however, there is no null check done in the subsequent lines of code. The PathResolver.relativePath() method is clearly marked with a "@CheckForNull" annotation, so I believe this is necessary. I am not sure if this is a bug with the PathResolver.relativePath() method, or an error with one of the inputs being sent to this method.

Julien HENRY

unread,
Oct 30, 2017, 11:34:21 AM10/30/17
to SonarQube
Hi,

Can you give me more details on your project structure. pathResolver returns null when the file is not a child of the first directory.

You say the base directory of scan is D:\jenkins\myworkspace\code\myproject

What is the Git repo root (where is located the .git file)?
Do you have a multi-module build, or symlink?

Do you confirm sources files (src/com/***/**.java) are located in D:\jenkins\myworkspace\code\myproject?

++

Julien

vijkr...@gmail.com

unread,
Oct 30, 2017, 12:10:51 PM10/30/17
to SonarQube
"D:\jenkins\myworkspace" is the shared workspace that I am using for the Jenkins job. I check out into a sub-directory called "code" - that's the directory with the .git folder. This is a multi module build, where "code\myproject" represents one module. So yes, the sources are located @ "D:\jenkins\myworkspace\code\myproject".

I tried a few things to eliminate as many possibilities as I could:
  • Tried removing the module configuration from the sonar properties file -> That did not work
  • Tried checking out directly into the workspace, instead of a sub-folder -> That did not work
  • Tried running the same job on a Linux slave -> that worked fine
Vijay

Julien HENRY

unread,
Oct 30, 2017, 12:20:46 PM10/30/17
to vijkr...@gmail.com, SonarQube
Can you run the job on Windows with verbose output (-X) and send me the logs (privately)?

Since the problem occurs only on Windows, I suspect a case sensitivity issue. Maybe for the drive letter.

Julien Henry | SonarSource

Developer

https://sonarsource.com


--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/M37HZ0Kbzcc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/db9b2bdd-20ee-483b-9bc3-c6fa5c7d71fb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

vijkr...@gmail.com

unread,
Oct 30, 2017, 12:55:18 PM10/30/17
to SonarQube
Hi Julien

You are probably right! I did a quick glance at the logs and noticed that the drive letter showed up in lower case in a few places (as in d:\jenkins\...). I sanitized the logs and sent them over to you privately.

The other thing I forgot to mention earlier is that I tried running this scan locally from a Windows laptop and that worked too! The issue occurs only when running from Jenkins, so it could be specific to the Sonar Jenkins plugin as well.

Thanks
Vijay
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

Julien HENRY

unread,
Oct 30, 2017, 1:13:35 PM10/30/17
to vijkr...@gmail.com, SonarQube
That's not the first time I face drive letter case sensitivity issue on Windows/Jenkins so this is not totally a surprise. I'll try to reproduce, and check if the problem still exist in upcoming LTS 6.7 (this is unlikely we'll fix it in 5.6).

Julien Henry | SonarSource

Developer

https://sonarsource.com


To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/34291b9e-139f-4d38-8d36-10e85a570f65%40googlegroups.com.

vijkr...@gmail.com

unread,
Oct 30, 2017, 2:01:07 PM10/30/17
to SonarQube
Thanks Julien, sounds good!

When is the LTS 6.7 release expected?

Vijay

Julien HENRY

unread,
Oct 31, 2017, 4:27:41 AM10/31/17
to Vijay Krishnan Ramaswamy, SonarQube
When is the LTS 6.7 release expected?

In one or two weeks (RC1 is already out).
Reply all
Reply to author
Forward
0 new messages