Sonar plugin

Plugin Information

Plugin ID sonar
Latest Release 1.3.1
Latest Release Date Feb 27, 2010
Changes via Fisheye In Latest Release
Since Latest Release
Maintainer(s) Evgeny Mandrikov (id: godin)
Simon Brandhof (id: sbrandhof)
Cedric Munger (id: cmunger)
Carlo Jelmini (id: cjelmini)
Issue Tracking Open Issues

Quickly benefit from Sonar, an open-source Code Quality Management Platform based on many well known analysis tools like Checkstyle, PMD, Findbugs, Cobertura, ....

Once your technical project is configured in Hudson, just activate the Sonar plugin in order to analyze your source code according to the following quality axes :

  • Respect of coding rules violations
  • Density of documented API
  • Density of duplicated Code
  • Level of code coverage by Unit Tests
  • Density of potential bugs
  • Complexity distribution
Why use Sonar?
  • There isn't any necessary configuration for Maven project and a basic one for Ant project
  • All those quality axes are displayed in one page : the project dashboard
  • You can easily drill down from the measure values to the module (Maven), package and classes (source code viewer)

Sonar drives many tools including among others :

Screenshots

All projects

Project dashboard

Configuration

  1. Install and start the Sonar server
  2. Activate the Sonar plugin from the Hudson Plugin Manager
  3. Define a Sonar installation from the Configure System page. Some advanced parameters are used when overriding default Sonar configuration.
  4. Activate Sonar on jobs from the "Post-build actions" section.
  5. Build your project
    We recommend to execute Sonar at the most on nightly builds. It's useless to activate it on continuous builds.
  6. View your project in Sonar application (default is http://localhost:9000)

Compatibility matrix

Plugin 1.0 1.1 1.2.2 1.3.1 1.4
Sonar 1.8+ 1.8+ 1.8+ 1.8+ 1.8+
Hudson 1.306+ 1.317+ 1.341+
1.344+ 1.344+

Support

Please post comments and questions on the Sonar mailing-list. Issues are listed in JIRA.

Older releases

Older releases can be found here: http://hudson-ci.org/download/plugins/sonar/

Release notes

Release 1.4 (not released)

This version incompatible with versions below 1.2.
If you are using version below 1.2, then there is two possible ways to upgrade to version 1.4:
  1. Recommended way:
    1. download version 1.2.2 or 1.3.1
    2. perform manual upgrade, using Manage Plugins -> Advanced -> Upload Plugin
    3. perform automatic upgrade to 1.4, using Manage Plugins -> Updates
  2. Another way:
    1. perform automatic upgrade to 1.4, using Manage Plugins -> Updates
    2. check and fix configuration

Release 1.3.1 (February 27, 2010)

Release 1.2.2 (February 3, 2010)

This version introduces some changes to configuration files. Upgrade will be performed automatically, but before upgrade please make a backup of your Hudson configuration.
Most probably next plugin version will be incompatible with versions below 1.2, so it's highly recommended to update to this version.

Release 1.1 (August 1, 2009)

When upgrading to this version, please be aware that "Skip on SCM build" (Default Yes) is becoming "Poll SCM" (Default No) under Triggers section. Due to technical limitation, this data could not be migrated to 1.1, and therefore if it was unchecked in certain jobs, the new box should be manually checked.

Release 1.0.1 (June 3, 2009)

Release 1.0 (May 20, 2009)

Labels:

plugin-external plugin-external Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Mar 27, 2009

    Robert Dale says:

    Will this run separate from any site reports so as to not interfere with findbug...

    Will this run separate from any site reports so as to not interfere with findbugs,checkstyle,pmd,etc graphs already in hudson? I understand that tests may run more than once, but it would be nice to continue to have quick at-a-glance metrics and trends in hudson, then be able to click off to sonar for deeper analysis.

    1. May 29, 2009

      Freddy Mallet says:

      Hi Robert, you're right and we've already got contributions from the Sonar commu...

      Hi Robert, you're right and we've already got contributions from the Sonar community (SONAR-852, SONAR-853, SONAR-854) so that the "Hudson Violations plugin" can automatically be fed with Sonar reports. This will be available with Sonar 1.10 (Begining of July).

  2. May 25, 2009

    Gabriel Casarini says:

    Hi, we're using Hudson 1.299, Sonar 1.8 and the latest version of the Sonar plug...

    Hi,
    we're using Hudson 1.299, Sonar 1.8 and the latest version of the Sonar plugin. Our projects are built with Ant. So far, the installation is ok (settings in Hudson, use MySQL, etc). But unfortunately, we have encountered a problem with the Sonar plugin. During the invocation we get this error:

    "Cannot execute mojo: sonar. It requires a project with an existing pom.xml, but the build is not using one"

    Looking at the error log (in Hudson), I have found the invocation command:

    mvn.bat -e -B sonar:sonar -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.username=sonar -Dsonar.jdbc.password=sonar -Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 -Dsonar.host.url=http://localhost:8081/sonar -f sonar-pom.xml

    Notice that "-f sonar-pom.xml" is at the END of the line, after all the -D properties.

    Doing the invocation myself (through the command line) and moving -f sonar-pom.xml BEFORE the -D Java switches, solves the problem

    So the problem is in the order of the parameters. Unfortunately, the invocation line is created by the plugin on the fly (using the settings configured in Hudson). And I cannot change it...

    Have you identified this same issue?

    Kindest regards,

    Gabriel

    1. May 29, 2009

      Freddy Mallet says:

      Hi Gabriel, I've created ticket SONARPLUGINS-100. This should be fixed with vers...

      Hi Gabriel, I've created ticket SONARPLUGINS-100. This should be fixed with version 1.1 of the Sonar Hudson plugin.
      Thanks for your help,
      Freddy

  3. May 27, 2009

    Edgar Miller says:

    Hi there, I am trying to install the plugin in Hudson 1.307, but getting alway...

    Hi there,

    I am trying to install the plugin in Hudson 1.307, but getting always an error while installation:

     com.thoughtworks.xstream.mapper.CannotResolveClassException: hudson.plugins.sonar.SonarPublisher:  hudson.plugins.sonar.SonarPublisher

    Have any idea?

    regards

    EdgarM


    P.S: I "downgraded" my hudson to 1.306 and the plugin worked immediatly.

    1. May 29, 2009

      Freddy Mallet says:

      See this thread. We can't manage to reproduce the issue.

      See this thread. We can't manage to reproduce the issue.

  4. Jun 22, 2009

    Ankit Mittal says:

    Hi , I am using Sonar Hudon Plugin , how should I configure the logger in Hudson...

    Hi , I am using Sonar Hudon Plugin , how should I configure the logger in Hudson to get logs for all level  in output console , right now I can see the Sonar Logs only if any build fail. I tried initializing logs on  hudson.plugin.sonar.* bu setting it in Log recorder , but I still cant see any logs

  5. Jul 29, 2009

    Lou Parisi says:

    Thanks for this plugin.  I am just trying out today and it seems very usefu...

    Thanks for this plugin.  I am just trying out today and it seems very useful.  Is there any way to add a link to the sonar project page from the hudson project page?

    1. Aug 05, 2009

      Freddy Mallet says:

      Good idea ! I've created JIRA ticket SONARPLUGINS-165.

      Good idea ! I've created JIRA ticket SONARPLUGINS-165.

  6. Sep 30

    Lasse Bergström says:

    Hi, I still get the same thing "Cannot execute mojo: sonar. It requires a proje...

    Hi,

    I still get the same thing "Cannot execute mojo: sonar. It requires a project with an existing pom.xml, but the build is not using one" as Gabriel gets above. We have 1.1 installed.

    Any clue?

    Best regards

    /Lasse

  7. Sep 30

    Lasse Bergström says:

    Hi, I still get the same thing "Cannot execute mojo: sonar. It requires a proje...

    Hi,

    I still get the same thing "Cannot execute mojo: sonar. It requires a project with an existing pom.xml, but the build is not using one" as Gabriel gets above. We have 1.1 installed.

    Any clue?

    Best regards

    /Lasse

  8. Jan 28

    a311955 says:

    I'm using Hudson 1.340, Sonar 1.9 and plugin version 1.1, but I cannot seem to g...

    I'm using Hudson 1.340, Sonar 1.9 and plugin version 1.1, but I cannot seem to get Hudson to see my Sonar installation.  The only choice for "Sonar Installation" dropdown list is "default".  When I tried to build anyway it told me "No Sonar installation on this job. , available installations count : 0"

    Sonar is installed at the default 9000 port and I can hit the URL, and both Hudson and Sonar are on the same server.

    1. Jan 28

      Evgeny Mandrikov says:

      Go to Hudson configuration page and configure Sonar installations.

      Go to Hudson configuration page and configure Sonar installations.

  9. Jan 28

    a311955 says:

    There's no installation to configure, the only choice is "default" and clicking ...

    There's no installation to configure, the only choice is "default" and clicking on that does nothing, ie. no new boxes to fill

    I forgot to mention we aren't using Maven, we use only ANT for building.

    Here's a screenshot: http://i47.tinypic.com/2ii7vox.jpg

    1. Jan 28

      Evgeny Mandrikov says:

      It would be better if you can provide screenshots. But in any case: have a look...

      It would be better if you can provide screenshots.

      But in any case: have a look on this article http://sonar.codehaus.org/a-new-hudson-plugin-for-a-closer-integration-with-sonar/

      1. Jan 28

        Evgeny Mandrikov says:

        And again: Go to Hudson global configuration page and configure Sonar installati...

        And again: Go to Hudson global configuration page and configure Sonar installations.
        Eg:
        1) my hudson installed here: http://localhost:8080/hudson
        2) global configuration can be found here: http://localhost:8080/hudson/configure
        3) Sonar installations can be added in section "Sonar" by pressing button "add"

        1. Jan 28

          a311955 says:

          Thanks for the quick reply, I'm past that point now.

          Thanks for the quick reply, I'm past that point now.

  10. Feb 02

    newguy says:

    I got this warning when trying to install 1.2.1 to Hudson 1.343: WARNING: Faile...

    I got this warning when trying to install 1.2.1 to Hudson 1.343:

    WARNING: Failed to resolve class
    com.thoughtworks.xstream.mapper.CannotResolveClassException: hudson.plugins.sonar.SonarPublisher : hudson.plugins.sonar.SonarPublisher

    and Hudson is unable to start after installing the plugin.

    1. Feb 10

      Evgeny Mandrikov says:

      Can you reproduce this with 1.2.2 version?

      Can you reproduce this with 1.2.2 version?

  11. Feb 03

    Jean-Pol Landrain says:

    Upgrade from 1.1 to 1.2.1 doesn't work for me (and Hudson was restarted, version...

    Upgrade from 1.1 to 1.2.1 doesn't work for me (and Hudson was restarted, version is 1.333).

    With 1.2.1, it tells that there is no maven goal specified on the command line.

    Reverted to 1.1 and it works again.

    1. Feb 03

      Wilfried Charpentier says:

      Hi, I'm facing the same problem with 1.2.1 and Hudson 1.343. Hudson was restart...

      Hi,

      I'm facing the same problem with 1.2.1 and Hudson 1.343. Hudson was restarted too.

      1. Feb 10

        Evgeny Mandrikov says:

        Take a look on this issue - http://jira.codehaus.org/browse/SONARPLUGINS-363 Is ...

        Take a look on this issue - http://jira.codehaus.org/browse/SONARPLUGINS-363
        Is it your case?

    2. Feb 10

      Evgeny Mandrikov says:

      BTW, plugin version 1.2.1 requires Hudson version 1.341

      BTW, plugin version 1.2.1 requires Hudson version 1.341

  12. Feb 25

    Paweł Stawicki says:

    Hi, I have one problem with this plugin. I have GWTTestCase tests in my project...

    Hi,

    I have one problem with this plugin. I have GWTTestCase tests in my projects. This tests needs DISPLAY. On Hudson problem is solved by Xvnc plugin. This plugin runs VNC on server, and there is DISPLAY ready to use for anything that needs it. Recently we introduced Sonar, and your great plugin. Sonar runs it's instrumented tests after maven build, and at this time VNC by Xvnc plugin is already closed. So my tests are all failed

    1. Feb 26

      Evgeny Mandrikov says:

      Hi Pawel, Thanks for your feedback. Could you please create ticket in Jira (htt...

      Hi Pawel,

      Thanks for your feedback.
      Could you please create ticket in Jira (http://jira.codehaus.org/browse/SONARPLUGINS/component/13726) for this issue?

  13. Mar 05

    Seshu Pasam says:

    We have a Maven 1.x project. I checked "Check if this project is NOT built with ...

    We have a Maven 1.x project. I checked "Check if this project is NOT built with maven 2." option for the job and filled in the required details. Not sure why, it is executing "maven" instead of "mvn" and failing because maven is not in the PATH.[workspace] $ maven -f pom.xml -e -B sonar:sonar -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://********:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 ******** ******** -Dsonar.host.url=http://*********:9000
    FATAL: command execution failed
    java.io.IOException: Cannot run program "maven" (in directory "/home/******jobs/************/workspace"): java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
    at hudson.Proc$LocalProc.<init>(Proc.java:149)
    at hudson.Proc$LocalProc.<init>(Proc.java:121)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:633)
    at hudson.Launcher$ProcStarter.start(Launcher.java:268)
    at hudson.Launcher$ProcStarter.join(Launcher.java:275)
    at hudson.tasks.Maven.perform(Maven.java:258)
    at hudson.plugins.sonar.utils.SonarMaven.executeMaven(SonarMaven.java:83)
    at hudson.plugins.sonar.SonarPublisher.executeSonar(SonarPublisher.java:401)
    at hudson.plugins.sonar.SonarPublisher.perform(SonarPublisher.java:352)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:582)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:563)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:550)
    at hudson.model.Build$RunnerImpl.post2(Build.java:152)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:528)
    at hudson.model.Run.run(Run.java:1233)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:122)
    Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
    at java.lang.ProcessImpl.start(ProcessImpl.java:65)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
    ... 19 more

    1. Mar 06

      Evgeny Mandrikov says:

      Hi Seshu, Thanks for your feedback. Just to clarify: I suppose that you use ...

      Hi Seshu,

      Thanks for your feedback.

      Just to clarify:

      • I suppose that you use latest version of Hudson Sonar Plugin
      • You have Maven 1.x project
      • You use free-style hudson job
      • Maven installation defined in Hudson Global Configuration
      • You specify Maven 2.x version in Sonar Configuration for your Job

      I'll going to check this, but just a bit later, so could you please create ticket in Jira http://jira.codehaus.org/browse/SONARPLUGINS/component/13726) for this issue?

      1. Mar 06

        Seshu Pasam says:

        Thanks Mandrikov for the prompt response. Yes Hudsona nd Sonar Plugins are the...

        Thanks Mandrikov for the prompt response.

        • Yes Hudsona nd Sonar Plugins are the latest version as of today
        • Yes I have a Maven 1.x plugin
        • Yes the job is free-style
        • Yes Maven 1.x and Maven 2.x are defined in Hudson Global Configuration (but I don't see these paths being used anywhere)
        • This is the part that I missed. I somehow missed the "Advanced" button on the Sonar tab. I have now selected the correct maven installation. Let me see how it goes

        Thanks again for your help

        1. Mar 06

          Evgeny Mandrikov says:

          Could you please inform me here, if it helps?

          Could you please inform me here, if it helps?

          1. Mar 07

            Seshu Pasam says:

            Hi Mandrikov, yes it worked. I missed the "Advanced" button part. I am stuck on ...

            Hi Mandrikov, yes it worked. I missed the "Advanced" button part. I am stuck on another problem now. I am getting the following when it is trying to run findbugs. I am running hudson 1.3.48 and Sonar 1.3.1. The project (site build) is already built. The <outputDirectory> and <sourceDirectory>/<source> are generated in pom.xml. Any idea?

            Caused by: org.sonar.api.utils.SonarException: Findbugs needs sources to be compiled. Please build project or edit pom.xml to set the property before executing sonar. at org.sonar.plugins.findbugs.FindbugsMavenPluginHandler.configureClassesDir(FindbugsMavenPluginHandler.java:99)

            Thanks

            1. yesterday at 06:42 PM

              Evgeny Mandrikov says:

              I think that this problem doesn't relate to Hudson Sonar Plugin, it relates to y...

              I think that this problem doesn't relate to Hudson Sonar Plugin, it relates to your configuration.
              Probably it would be better - post to Sonar mailing list. And it would be nice, if you can provide test project and your job configuration.