Skip to end of metadata
Go to start of metadata
By SonarSource – GNU LGPL 3 – Issue TrackerSources – Supported by SonarSource
More versions
Git 1.4.1 – May 23, 2017 – SonarQube 6.7+ (Compatible with LTS)
Bug fix for short-lived branches and P/R analyses
DownloadRelease notes

Description

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.

Usage

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).

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

Advanced information

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 PluginJGit
1.03.6.2
1.13.6.2
1.24.2.0
1.34.6.0
1.44.9.0

2 - Download standalone JGit command line distribution

https://repo.eclipse.org/content/groups/releases/org/eclipse/jgit/org.eclipse.jgit.pgm/<version>/org.eclipse.jgit.pgm-<version>-r.sh

3 - Try to execute the blame command on the offending file

chmod +x /where/is/org.eclipse.jgit.pgm-<version>-r.sh
/where/is/org.eclipse.jgit.pgm-<version>-r.sh blame -w /path/to/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.

 

  • No labels