SonarQube 5.1.2 and maven 3.3 integration - maven

I am trying to integrate SonarQube 5.1.2 with Maven 3.3. But I think it's only supported till SonarQube version 5.1.
When I run mvn sonar:Sonar
Embedded error: Unable to build project for plugin 'org.codehaus.sonar:Sonar-mav
en-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:5.1.2
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
Any thoughts?

The correct command-line is mvn org.codehaus.mojo:sonar-maven-plugin:sonar (see the difference of groupId). It is supported by all versions of Maven 3 and SonarQube.

sonar:Sonar != sonar:sonar beware of the spelling.

Related

Latest release of sonar maven plugin is broken

It looks like they released latest version of sonar maven plugin which is under org/sonarsource/scanner/maven/sonar-maven-plugin/3.8.0.2131/
However it has a dependency below that is missing in the public maven repos :-
org.sonarsource.scanner.api:sonar-scanner-api:jar:2.16.0.226
The latest version i could find for this dependency is 2.15.0.2182 available in public repos
This is causing most of our build failures now where we use sonar goal in maven. I know we can fix this by specifying the version something like below :-
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar
However, that would require us to make changes in a number of places.
Is anyone in the community aware of this and if so do we know if they are going to fix the latest version of sonar maven plugin and make all its dependencies available?
For the moment you can specify in your Jenkins job the version of the plugin :
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar
SonarSCanner for Maven

How to search with maven plugin in archiva

Using this maven plugin:
http://www.mojohaus.org/versions-maven-plugin/index.html
With this command line:
mvn versions:display-dependency-updates
Maven can connect to Archiva to retrieve the list of dependencies a project is using and check if it uses the latest version of it.
How does it work? Does maven use HTTP to retrieve the information?
We found everything we need there :
Eclipse Aether website

sonar-maven-plugin 5.1.1 not found

I've just installed the latest version of SonarQube (5.1.1) and when I try to run the sonar:sonar target, I get an error:
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:5.1.1
I've checked here:
http://mvnrepository.com/artifact/org.codehaus.sonar/sonar-maven-plugin
And it seems that version 5.1.1 of the sonar-maven-plugin has not been pushed to the public repo(s).
Is that so or am I looking in the wrong location?
The sonar-maven-plugin is an independent project that does not follow SonarQube versioning.
Correct command-line is mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
The groupId mvn.codehaus.sonar is for internal use.

Integrating sonarqube with Jenkins

I am trying to run sonar sonar:sonar by integrating sonarqube and jenkins. While doing, am getting the below error.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project iwm_common: Can not execute SonarQube analysis: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext -> [Help 1]
Jenkins version - 1.612
Sonarqube version - 3.6
JDK-1.7.0_76
Maven - 3.1.1
Jenkins WAR is deployed in server A and sonarqube is deployed in server B. I have not installed sonar-jenkins plugin in Jenkins.
Can anyone let me know whether sonar-jenkins plugin is mandatory to be installed in jenkins to integrate jenkins with any sonar server (eg:sonarqube).
If the answer is YES, then after installation of the required plugin, will adding the sonar server (eg:sonarqube) information under Manage Jenkins -> Configure system -> sonar resolve the above error ?
The error is related to sonar-maven-plugin and this plugin is not used in any of the project's pom.xml. Can anyone please explain whether this plugin gets referred as a part of sonar:sonar goal. Thanks.
The versions you specified are not compatible for running sonar analysis.
Please upgrade SonarQube version (current is 5.1.1) which requires
Java 1.7-1.8
SonarQube 5.0 or 5.1.1
Sonar-runner 2.4
Using latest version of sonarqube resolved the issue mentioned.

Configuring Maven, jenkins with Sonar

I have installed Jenkins and Sonar, both work fine. I am able to build a maven android project using Jenkins. No i want to run Sonar on the android project. I have installed the Sonar plugin in Jenkins. Configured the sonar module in the configure system module and added a post build task for sonar to run
[ERROR] Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar: Could not find artifact org.codehaus.mojo:sonar-maven-plugin:pom:sonar in nbs-repo (http://10.10.2.89:8081/nexus/content/groups/public/) -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:235)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
at
My nexus installation works fine ? What am i doing wrong. My maven pom.xml does not contain any sonar plugin. What am i doing wrong?
Kind Regards
From the error message its clear that mvn is trying to download the sonar-maven-plugin from your local Nexus repository which does not seem to have it.
Try mvn -U in the build in case you already have the plugin.This overrides the negative cache. Another thing is <updatepolicy> in your settings.xml
If you don't have the plugin and neither does your Nexus connect to the internet, you have to manually download and upload in Nexus of course. Please remember to match the version of the plugin with the SONAR installation. Also there would be a few (7-10) transitive dependencies with the plugin which you will need. I suggest using mvn -X or mvn -e to see a verbose output during your testing.

Resources