Skip to end of metadata
Go to start of metadata

Plugin Information

View SonarQube Scanner on the plugin site for more information.

Documentation of SonarQube plugin available in SonarQube wiki

http://redirect.sonarsource.com/plugins/jenkins.html
Please don't use this page to ask questions or report bugs.

This plugin allow easy integration of SonarQube™, the open source platform for Continuous Inspection of code quality.

54 Comments

  1. Unknown User (robdale@gmail.com)

    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. Unknown User (freddy.mallet)

      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. Unknown User (gabriel.casarini@gmail.com)

    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 (wink)

    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. Unknown User (freddy.mallet)

      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. Unknown User (edgarm)

    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. Unknown User (freddy.mallet)

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

  4. Unknown User (alookachaloo)

    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. Unknown User (lou.parisi@photomask.com)

    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. Unknown User (freddy.mallet)

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

  6. 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. 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. Unknown User (a311955@fmr.com)

    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. Go to Hudson configuration page and configure Sonar installations.

  9. Unknown User (a311955@fmr.com)

    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. 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. 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. Unknown User (a311955@fmr.com)

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

  10. Unknown User (newguy)

    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. Can you reproduce this with 1.2.2 version?

  11. 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. Unknown User (wil80)

      Hi,

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

    2. BTW, plugin version 1.2.1 requires Hudson version 1.341

  12. 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 (sad)

    1. 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. Unknown User (pasam)

    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. 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. Unknown User (pasam)

        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. Could you please inform me here, if it helps?

          1. Unknown User (pasam)

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

  14. Unknown User (subscriptions@jigarshah.net)

    I am getting following log in build console. I am using ant. (not maven)

    (I can post my config here.)

    In console output it says...

    "Skipping sonar analysis due to bad build status UNSTABLE"

    I do want to build even if test is unstable.

    I havej unit tests being run.
    I have pmd reports being generated through ant.
    I have multiple classes directory. (So can i specify comma separated list ?)

    Can I reuse pmd reports generated by my build. ? I don't see config for the same.

    How do i configure sonar ?

    1. > I do want to build even if test is unstable.
      See triggers configuration (it can be defined for job or globally) - there is checkbox "Skip analysis on build failure".

      > I have multiple classes directory. (So can i specify comma separated list ?)
      Only one classes directory supported.

      > Can I reuse pmd reports generated by my build?
      For now you can reuse surefire, cobertura and clover reports.

      Feel free to split your issues into separate tickets and create them in Jira (http://jira.codehaus.org/browse/SONARPLUGINS/component/13726).

  15. Unknown User (subscriptions@jigarshah.net)

    For removing duplicate of above. I really appreciate any help

  16. Unknown User (a311955@fmr.com)

    From where does the plugin grab rulesets for pmd, checkstyle and findbugs?  I would like to use our own but there's no place to specify them?  This is with version 1.4 of the plugin and 1.350 Hudson.

    1. Plugin just invokes "mvn sonar:sonar" with some additional parameters. You can configure rules through Sonar web interface.

  17. Unknown User (a311955@fmr.com)

    Another question, is there a way to add exclusion lists from the plugin, like for generated files?

  18. Hi,

    I use Hudson 1.352 and a Sonar plugin with MySql.  Our project is built with ANT. I've followed all the described installation steps and the Sonar creates 25 tables in the DB. After a build only a project  name appears in the Sonar, but nothing else no graphics...and I get this error is the Sonar log

    2010.03.26 23:08:48 ERROR rails 
    ActionView::MissingTemplate (Missing template charts/trends.erb in view path /home/user/sonar/sonar-2.0.1/war/sonar-server/WEB-INF/app/views:):
        /gems/gems/actionpack-2.2.2/lib/action_view/template.rb:95:in `find_full_path'
        /gems/gems/actionpack-2.2.2/lib/action_view/template.rb:16:in `initialize'
        /gems/gems/actionpack-2.2.2/lib/action_view/base.rb:332:in `_pick_template'
        /gems/gems/activesupport-2.2.2/lib/active_support/memoizable.rb:99:in `_pick

    Any ideas?

    Thanks in advance!

    1. Hi Elena,

      This issue doesn't relates to Hudson Sonar Plugin, it relates to Sonar, so could you please write about your problem to Sonar user mailing list?

  19. About the issue SONARPLUGINS-355.
    I'm using the version 1.5 with hudson 1.351, and the sonar URL in my project still takes me to sonar homepage.

    Great plugin you developed, thanks.

  20. Unknown User (eklein)

    I am building a Sonar PlugIn that will make use of the Maven2 POM that Sonar automatically produces via its Hudson Plugin.  I need to add a few XML sections to the sonar-pom.xml file that gets generated to handle Ant-based builds.  Please confirm that the file I should update is sonar-light-pom.template.

    Also, which Maven goals does Sonar execute via this PlugIn interface?  I see an area to specify MAVEN_OPTS and Additional Properties, but no place to indicate the goals to be executed.  Are the goals supposed to be executed within my PlugIn or does Sonar perform some Maven goals as well?

    1. Could you please switch to sonar developers mailing list in order to investigate your issue?

  21. Hudson Sonar plugin stopped working after upgrading Sonar from 1.12 to 2.1.2

    For any reason, it requires a class and cannot find it. Build logs show:

    trunk $ C:\programs\selenium\apache-maven-2.2.1\bin\mvn.bat -f pom.xml -e -B sonar:sonar -Dsonar.jdbc.driver=com.mysql.jdbc.Driver "-Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8" ******** ******** -Dsonar.host.url=http://vm-0019:9000/
    ...
    FATAL ERROR org.sonar.maven2.BatchMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
    FATAL ERROR Plugin realm = app0.child-containersonar-core-maven-plugin:20100611111942
    ...
    FATAL ERROR Container realm = plexus.core
    urls0 = file:/C:/programs/selenium/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar
    FATAL ERROR org.codehaus.mojo.sonar.SonarMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
    FATAL ERROR Plugin realm = app0.child-containersonar-maven-plugin:1.0-beta-1
    urls0 = file:/C:/axa/maven/.m2/repository/org/codehaus/mojo/sonar-maven-plugin/1.0-beta-1/sonar-maven-plugin-1.0-beta-1.jar
    urls1 = file:/C:/axa/maven/.m2/repository/commons-io/commons-io/1.3/commons-io-1.3.jar
    urls2 = file:/C:/axa/maven/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
    urls3 = file:/C:/axa/maven/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
    FATAL ERROR Container realm = plexus.core
    urls0 = file:/C:/programs/selenium/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar
    INFO ------------------------------------------------------------------------
    ERROR FATAL ERROR
    INFO ------------------------------------------------------------------------
    INFO org/sonar/api/utils/IocContainer
    INFO ------------------------------------------------------------------------
    INFO Trace
    java.lang.NoClassDefFoundError: org/sonar/api/utils/IocContainer
    at org.sonar.batch.AggregatorBatch.createContainer(AggregatorBatch.java:52)
    at org.sonar.batch.AggregatorBatch.<init>(AggregatorBatch.java:48)
    at org.sonar.maven2.BatchMojo.executeBatch(BatchMojo.java:136)
    at org.sonar.maven2.BatchMojo.execute(BatchMojo.java:131)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:82)
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:117)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

    Any ideas?

    Thanks in advance!
    Al

    1. Could you please switch to sonar users mailing list in order to investigate your issue?

  22. Unknown User (coutemeier)

    I think it would be great if you add an option to launch automatically a Sonar analyse after M2 Release plugin, with the label of the event in Sonar as the version number generated in release process.

    Another way to get this, would be if there were an option to launch a Sonar analyse after a build.

    In both cases, the use of a -Dsonar.isARelease (#current|#previous|a number of version) parameter would help to indicate sonar if the version number must be overriden with the #current or #previous (in the release file used by Maven), or a number of version as 1.2.23.

    1. Hi, Could you please Sonar user mailing list ( http://www.sonarsource.org/support/support/ ) for discussions about new features and so on ?

  23. where is the plug in..?  there are screenshots, but not acutal application...???

  24. The plugin is exposing the passwords for the DB and for sonar.  The masking password plugin does not include Sonar.  Please include in the next version a flag to hide or mask these values.  Thanks in advance.

    Example of the Jenkins consoleworkspace $ cmd.exe /C '"D:\maven\apache-maven-3.3.3\bin\mvn.bat -f D:\Jenkins\jobs\CtsCommon\workspace\pom.xml -e -B sonar:sonar """-Dsonar.jdbc.url=jdbc:mysql://203.3.10.126:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true""" -Dsonar.jdbc.username=sonar -Dsonar.jdbc.password=PASSWORD_IN_CLEAR_TEXT -Dsonar.host.url=http://sc0226v.us.mhfg:9000 -Dsonar.login=sonar -Dsonar.password=PASSWORD_IN_CLEAR_TEXT && exit %%ERRORLEVEL%%"'

  25. I can see that the 2.5 release of this plugin was scheduled to be resolved by 9/30.  Can we get a status on where things are?

    1. Release done, sorry for the delay.

  26. @Julien: Could you document the the list of supported environment variables that the Jenkins plugin supports in https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins (don't have any access there)?  I had to search github (https://github.com/SonarSource/sonar-scanner-jenkins/search?utf8=%E2%9C%93&q=sonar.login) to find out that the token is in variable "SONAR_AUTH_TOKEN" and typically you would have to use "-Dsonar.login=$SONAR_AUTH_TOKEN" which is not self-explanatory I think....

  27. Hello,

    I am trying to figure out how to install the MS Build Scanner and regular Sonar Scanner global tools from a groovy init script. I was able to use SonarGlobalConfiguration to setup the Sonar configuration pointing to an installation. Now I am just trying to do the same thing using the groovy script so it will already be setup on jenkins instance startup. I started looking at MsBuildSQRunnerInstallation but must be doing something wrong cause it isn't working and there isn't much info around this type of automation.