SonarQube MSBuild scanner error in Git worktree

scanner
msbuild

(Sylvain) #1

The scan fails if the source code of a git branch is checked out in a worktree. In that case “.git” is a file containing the location of the actual “.git” directory for that worktree.

SonarQube: 7.3.0.15553
SonarQube Scanner MSBuild 3.2.0.1227
Git plugin 1.4.1.1128

Scanner log error of Jenkins job:
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to open Git repository
ERROR: Caused by: repository not found: F:\Sources\repositories\tools.git\worktrees\worktree-name

Content of “F:\Sources\worktrees\worktree-name.git” file inside the worktree directory:

gitdir: F:/Sources/repositories/tools/.git/worktrees/worktree-name

The scanner has to resolve the content of the “.git” file to the actual “.git” directory.

We want to analyze multiple branches on the same machine, with worktrees we can checkout multiple branches at the same time from the same repository.
The workaround of having multiple clones of the same Git repository is not an option because our source code is too large.


(Janos Gyerik) #4

Hi,

I took a closer look. For Git operations we’re using the JGit library, and this problem work worktrees is a known issue in their bug tracking system. It seems a fix is a work in progress, with important activity this year. Once they release the fix, we can update our dependency. I’m afraid we can’t do more at this point.

I created a ticket to track this issue: https://jira.sonarsource.com/browse/SONARSCGIT-31

Cheers,
Janos