Implements SCM dependent features of SonarQube for Git projects. Pure Java implementation so no need to have Git command line tool installed on the computer doing the SQ analysis.
Install the plugin in SonarQube. Auto-detection will work if there is a .git folder in the project root directory or in one of its parent folders. Otherwise you can force the provider using
-Dsonar.scm.provider=git. A full clone is required to collect the required blame information (see Known Issues).
- Trying to collect blame on a shallow clone may either collect incorrect data or fail with an error like:
ERROR: Caused by: Unable to blame file some/file.xy
ERROR: Caused by: Missing commit 2f7227db7567a8858495074e8ceb915cd0f54ddd
Full clone is required to collect all needed information.
Since 1.3 the plugin will log a warning when a shallow clone is detected, and files will not be blamed.
- Git doesn't consider old "Mac" line ends (CR) as new lines. As a result the blame operation will contains fewer lines than expected by SonarQube and will fail the analysis. The solution is to fix line ends to use either Windows (CR/LF) or Unix (LF) line ends.
- JGit doesn't support .mailmap file to "clean" email adress during the blame
The plugin uses the JGit pure Java implementation of Git client: https://www.eclipse.org/jgit/
How to investigate error during blame (only possible on Unix/Linux)?
If you get an error when blame is executed on a file this may be a limitation or a bug in JGit. To confirm please follow these steps:
1 - Identify version of JGit that is used:
|SonarQube Git Plugin||JGit|
2 - Download standalone JGit command line distribution
3 - Try to execute the blame command on the offending file
4 - If you get the same error than during the SQ analysis then this really looks like a bug in JGit (especially if you don't have issue with the native git command line tool). Please try to do previous steps with latest version of JGit and feel free to report the issue in details on SonarQube Community Forums.