1
votes

I have been trying to integrate Sonar with our Jenkins continous Integration system. I have installed the Sonar-plugin for Jenkins and configured it(specified the DB, DB Username and password etc). I have also specified the sonar-maven-plugin version as 1.0-beta-2.

Along with this plugin configuration, I have added a build post-action to run Sonar on my maven projects. But everytime Jenkins tries to execute sonar:sonar goal it fails with the below error.

Please help me guys in resolving this problem.

Thanks

[INFO] Building prof
[INFO]    task-segment: [org.codehaus.mojo:sonar-maven-plugin:1.0-beta-2:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://inmqbs:9000
[INFO] Sonar version: 3.3.2
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:3.3.2:sonar
Downloading: http://troop:8081/nexus/content/groups/platform//org/codehaus/sonar/sonar-maven-   plugin/3.3.2/sonar-maven-plugin-3.3.2.pom
[INFO] Unable to find resource 'org.codehaus.sonar:sonar-maven-plugin:pom:3.3.2' in repository troop-maven-releases (http://troop:8081/nexus/content/groups/platform/)
Downloading: http://troop:8081/nexus/content/groups/platform//org/codehaus/sonar/sonar-maven-plugin/3.3.2/sonar-maven-plugin-3.3.2.pom
[INFO] Unable to find resource 'org.codehaus.sonar:sonar-maven-plugin:pom:3.3.2' in repository  central (http://repo1.maven.org/maven2)
Downloading: http://troop:8081/nexus/content/groups/platform//org/codehaus/sonar/sonar-maven-plugin/3.3.2/sonar-maven-plugin-3.3.2.pom
[INFO] Unable to find resource 'org.codehaus.sonar:sonar-maven-plugin:pom:3.3.2' in repository troop-maven-releases (http://troop:8081/nexus/content/groups/platform/)
Downloading: http://troop:8081/nexus/content/groups/platform//org/codehaus/sonar/sonar-maven-plugin/3.3.2/sonar-maven-plugin-3.3.2.pom
[INFO] Unable to find resource 'org.codehaus.sonar:sonar-maven-plugin:pom:3.3.2' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: Unable to build project for plugin 'org.codehaus.sonar:sonar-maven-plugin':  POM 'org.codehaus.sonar:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository

  org.codehaus.sonar:sonar-maven-plugin:pom:3.3.2

  from the specified remote repositories:
  internal-repository (http://troop:8081/nexus/content/groups/platform/)

  for project org.codehaus.sonar:sonar-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals  (DefaultLifecycleExecutor.java:719)
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:597)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103)
at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79)
at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals (DefaultLifecycleExecutor.java:694)
... 17 more
3
have you tried from the command line ? to rule out problems with JenkinsPulak Agrawal
Yes,it is throwing the same error on doing mvn sonar:sonaruser1522820

3 Answers

2
votes

The problem clearly comes from your Nexus repository or from some specific configuration that you've made in your POM / settings.xml file / Jenkins settings. You should contact the guys who handle this "http://troop:8081" Nexus instance to know how to deal with your issue.

BTW, there's no need to force the version of the sonar-maven-plugin plugin: this will cause you only troubles.

0
votes

what database are you using?, if it defaults to derby database then only connections from the localhost are allowed and thus sonar and jenkins should run in the same machine. If this is the problem i can give further guidance but in a nutshell either change the database, or change the derby connection properties or provide a ssh tunnel between sonar and jenkins machines.

0
votes

Use in the your configuration sonar-maven-plugin 2.0-beta-1 instead sonar-maven-plugin:1.0-beta-2