Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{iframe:src=http://update.sonarsource.org/plugins/scmactivity-confluence.html|width=700|height=250350|frameborder=0}
Your browser does not support iframes.
{iframe}
Info
iconfalse
titleTable of Contents

Table of Contents
maxLevel1

Compatibility Matrix

...

Description / Features

This plugin collects SCM blame information and displays the date of the commit and the commiter ID to the left of each line of code:

Image Added

This plugin also enables the computation of:

 

This plugin is enabled by default for all projects. The SCM Activity plugin can be disabled on a project-by-project basis, or disabled globally at Settings > General Settings > SCM Activity and then enabled on a project-by-project basis.

Requirements

All SCM providers currently require the native executable to be installed on  on the server where the Sonar SonarQube analysis will run. For example, for projects hosted on a Subversion repository and analysed on a Jenkins server, an svn executable must be available on  on the Jenkins server (and its slaves if any).

(tick) - supported

(star) - tested by users

(question) - not tested

(error) - not implemented

Features

This plugin collects SCM information on each source file to display in the source code viewer the last committer on lines.

Image Removed

Installation

  1. Install the SCM Activity plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
  2. Restart the Sonar server

Include Page
Include - Plugin Installation
Include - Plugin Installation

Usage

Configuring the SCM Activity Plugin

...

Set the SCM URL of your project (see SCM URL Format): sonar.scm.url properties. For Git, SVN and Mercurial, the SCM provider is automatically discovered, so what's defined in this property is not taken into account.

...

: SVN, Git, Mercurial and Team Foundation Server (TFS)

Information is automatically retrieved from the .git, .svn, $tf, etc. folders. Therefore, nothing has to be configured and no configuration will be taken into account.

In order for this to work, the sonar-project.properties file needs to be located in a checked-out folder, but it does not have to be checked-in.
Alternatively, you can set the "sonar.projectBaseDir" property to a checked-in folder (requires sonar-runner 2.4 at least), and have the sonar-project.properties files located anywhere.

Configuring the SCM Activity Plugin: Others

At the project level, go to Configuration > Settings > SCM Activity

...

  1. Set the SCM URL of your project (see SCM URL Format).

  2. Specify the User and Password properties if needed. If the SCM URL property contains the user information (as with CVS), then these fields should be left blank.
  3. Launch a new quality analysis and the metrics will be fedcomputed.

 

Infonote
titlePerformance

The first analysis of a project with version 1.4 will last longer than the subsequent analyses.

Forcing the Retrieval of Blame Information

In some cases, it is necessary to retrieve blame information on files that have not been changed (for example when a user has been renamed). To force this retrieval, here are the steps to follow:

  1. Deactivate the SCM Activity plugin: sonar.scm.enabled = false
  2. Run a Sonar analysis on your project
  3. Reactivate the SCM Activity plugin: sonar.scm.enabled = true
  4. Run a Sonar analysis on your project
Security note for SonarQube 3.4.0 to 3.6.3 included

For the *.secured properties to be read during the project analysis, it is necessary to set the sonar.login and sonar.password properties to the credentials of a user that is:

  • System administrator
  • And project administrator on the project that is being analyzed
Example:
sonar-runner -Dsonar.login=admin -Dsonar.password=admin

 

Forcing the Retrieval of Blame Information

 

Info

Note that a property should be added sooner or later to explicitly force this retrieval or not. See SONARPLUGINS-2359.

Known Issues and Limitations

 

Troubleshooting

Subversion "Server certificate verification failed: issuer is not trusted"

Add the following to .subversion/servers:

Code Block
[global]
ssl-authority-files = /path/certificate.crt
ssl-trust-default-ca = yes

CVS anonymous access not working "org.apache.maven.scm.ScmException: password is required."

Try to set setting an empty password for the repository in .cvspass. For example:

Code Block
xml,title.cvspass
/1 :pserver:anonymous@javacaltools.cvs.sourceforge.net:2401/cvsroot/javacaltools A

I use Git and the annotated sources sometimes display a wrong/old author name

The plugin uses the 'git blame' command to find out get the author of each line. Because a single user can commit with different multiple author namenames/emailemails, it is advised to have a .mailmap file at the root of the repository. This file is used by 'git blame' to find out determine the canonical name/email of each user.

See http://git-scm.com/docs/git-blame#_mapping_authors

Change Log

JIRA Issues
anonymoustrue
titleRelease 1.5
height70
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=18567&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleRelease 1.4
height70
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=17309&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleRelease 1.3
height250
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=17276&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

Note

See Sonar 2.7 Upgrade Notes

JIRA Issues
anonymoustrue
titleRelease 1.2
height250
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=16455&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleRelease 1.1
height250
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=16286&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleRelease 1.0
height250
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=16222&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleRelease 0.2
height250
renderModestatic
width800
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=16192&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

...

I use Git and the annotated sources sometimes display "Not Committed Yet"

If you have set the parameter autocrlf to "true" or "input", and the source file was previously committed with Windows line endings, then git blame will report each line as "Not Committed Yet" as an indication that the file will be normalized to Unix line endings in case you do a modification and a commit on the same file.

The simplest workaround is to always set autocrlf to "false" on the box doing the SonarQube analysis.

Specific configuration for Jazz RTC

The number of threads used to speed-up the retrieval of authors by line (aka blame information) has to be set to '1' (sonar.scm.threadCount property).

Additional configuration for Perforce

Since version 1.6, you have to set an additional property to define the Perforce client name while running your analysis: sonar.scm.perforce.clientspec.name.

Example:

Code Block
languagenone
sonar-runner -Dmaven.scm.perforce.clientspec.name=myPerforceClientName