Juee J
Juee J

Reputation: 21

why maven-sonar-plugin doesnot exist?


I am facing a similar issue as in https://issues.apache.org/jira/browse/MNG-4001 but with maven-sonar-plugin.
Versions i am using are: Jenkins - 1.580.1, SonarQube-plugin in Jenkins -2.1, tried with Sonar 4.0 and SonarQube 4.5.1 but faced same error, sonar-maven-plugin: 2.6 /2.7.1 (tried both)
I face this error when i use Sonar post build step in my Jenkins configuration and this is frequent issue seen in different jobs
Error is

 [INFO] Searching repository for plugin with prefix: 'sonar'.
 [INFO] artifact org.apache.maven.plugins:maven-sonar-plugin: checking for updates from central
 [INFO] artifact org.apache.maven.plugins:maven-sonar-plugin: checking for updates from snapshots
 [INFO] ------------------------------------------------------------------------
 [ERROR] BUILD ERROR
 [INFO] ------------------------------------------------------------------------
 [INFO] The plugin 'org.apache.maven.plugins:maven-sonar-plugin' does not exist or no valid version could be found
 [INFO] ------------------------------------------------------------------------
 [INFO] Trace
 org.apache.maven.lifecycle.LifecycleExecutionException: The plugin 'org.apache.maven.plugins:maven-sonar-plugin' does not exist or no valid version could be found
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1569)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
     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.version.PluginVersionNotFoundException: The plugin 'org.apache.maven.plugins:maven-sonar-plugin' does not exist or no valid version could be found
     at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:229)
     at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:91)
     at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:179)
     at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
     ... 15 more
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 2 seconds
 [INFO] Finished at: Wed Dec 16 13:13:35 CET 2015
 [INFO] Final Memory: 7M/238M
 [INFO] ------------------------------------------------------------------------
 Sonar analysis completed: FAILURE
 Build step 'Sonar' changed build result to FAILURE
 Build step 'Sonar' marked build as failure
 Finished: FAILURE

why am i facing this error ? is the issue(bug) with Sonarqube plugin in Jenkins?
for time being to avoid this error i have deleted Sonar post build step and added the sonar analysis step in maven goals for maven 3.0.4

 Maven goals :: clean install -Dmaven.test.skip=true -Dsonar.jdbc.url=jdbc:postgresql://sonardb.test.com:5555/sonar -Dsonar.host.url=http://localhost:9000/sonar org.codehaus.mojo:sonar-maven-plugin:2.6:sonar <br> 

but this is a temporary solution, I would like to use Sonar post build step in my job configuration and not face this error.
Thanks for your help

Upvotes: 1

Views: 2606

Answers (2)

Nicolas B.
Nicolas B.

Reputation: 7331

SonarQube FAQ recommends the following:

If you get this error message after launching the maven command line "mvn sonar:sonar" add the "-U" parameter to the command line. Maven will then update its local repository with the latest version of the Sonar Maven plugin.

If adding the "-U" parameter doesn't fix your issue, you've certainly encountered Maven bug MNG-4001. The only known workaround is to delete the org\codehaus\mojo directory in your local Maven repository. Of course, if your local Maven repository is synchronized with a repository manager like Nexus, this operation must be also done on the repository manager side.

Upvotes: 1

khmarbaise
khmarbaise

Reputation: 97517

The problem is simply cause you are using the wrong coordinates of the plugin:

'org.apache.maven.plugins:maven-sonar-plugin'

The sonar-maven-plugin is not part of Apache Software Foundation.

You will find it here:

http://www.mojohaus.org/sonar-maven-plugin/

And how to use it here:

http://www.mojohaus.org/sonar-maven-plugin/plugin-info.html

Upvotes: 0

Related Questions