SonarQube Eclipse doesn't show me issues after a local analysis - sonarqube

Using SonarQube Eclipse plugin, I run remote analysis [Sonar > Mode > Remote] (localhost:9000 and ip_on_my_lan:9000) and I see Sonar Issues tab with some elements (everything is OK).
But if I run local analysis I don't have any issue on Sonar Issues tab and Eclipse deletes all issues marks from source code.
It seems sonar-runner local analysis was OK: INFO - ANALYSIS SUCCESSFUL
What I'm doing wrong?
I tried with:
Eclipse Kepler, Sonar 3.7, SonarQube Plugin 3.0 and 3.2
Eclipse Juno, Sonar 3.7, SonarQube Plugin 3.0 and 3.2
Thanks for your time.

I found the problem!!!!
I have my sources on src/test/java instead of src/main/java (test framework)
If I run my analysis with "sonar-runner.bat" everything is ok, but when I run a local analysis from eclipse it seems eclipse doesn't found any source, but it doesn't say anything...
Eclipse put the binary code on /target/test-classes/ and I think Sonar plugin can't found it.
So I have two options: Move my source to src/main/java (checked) or create new local analysis properties (sonar.binaries)
Thanks for your time!

Related

Uploading Spock/Groovy test results into Sonarqube

There was a known issue from 2014 that UnitTests written in Groovy cannot have their PASS/FAIL metrics uploaded into SonarQube.
http://sonarqube-archive.15.x6.nabble.com/Resource-not-found-for-Groovy-unit-tests-td5024669.html
Does anyone know if this issue is fixed? I am still have the issue with Sonar 6.1 using Spock unit tests and Gradle build system.
Any clue on the correct gradle sonar settings to make this happen?
The solution for us was to install the Groovy plugin in Sonarqube 6.1.
Once the plugin was installed, we could see the tests, with this command line:
./gradlew sonarqube -Dsonar.tests=src/test/groovy -Dsonar.junit.reportsPath=build/test-results/test/
We are using Spock as well (with Gradle, as you can see)

Inconsistent sonar reports

I ran sonar analysis on a project in two ways
From command prompt using sonar-runner -X command
As a maven goal using sonar:sonar(Java 1.8) and org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (java 1.6)
Both scans resulted in two different reports. I don't know why this happened.
Below is my development environment configuration
Maven: 3.0.5
Sonarqube: 3.0.1
Sonar-runner: 2.4
Eclipse: Kepler
Java: 1.6
Sorry guys, my mistake. While analysing from command prompt sonar.source is set to scr. So sonar analysed test code also.
Where as mvn sonar:sonar analysed only src/main/java

How to use SCM Activity plugin in sonar for clearcase

Changed my sonar for scm activity from 3.7 to sonarqube 5.1.1 as it has in built in scm plugin.
Not getting what are the configurations needed to run that and what to pass in
setting->genral setting->scm->sonar.scm.provider
I found this link
http://maven.apache.org/scm/clearcase.html
and created a
URL:- scm:clearcase:baxi_view_4:clinical
Error
org.apache.maven.plugin.MojoExecutionException: SCM provider was set to "scm:clearcase:baxi_view_4:clinical" but no SCM provider found for this key. Supported SCM providers are git,svn
and what other changes or configuration needed in my code or is there anything i have to specify in pom.xml.
I am using jenkins and sonar Integration for CI and reports
You have to install ClearCase plugin for SonarQube. Since there is no official release download a SNAPSHOT from:
https://github.com/SonarCommunity/sonar-scm-clearcase/releases/download/1.0-rc1/sonar-scm-clearcase-plugin-1.0-SNAPSHOT.jar
Plugin documentation is here:
http://docs.sonarqube.org/display/PLUG/ClearCase+Plugin
Make sure to add sonar.scm.provider=clearcase into sonar.properties and re-run SonarQube analysis.
N.B.: We are waiting for positive feedback (on SonarQube Google group) before doing an official release since we do not have Clearcase instance for testing.
Install ClearCase plugin for SonarQube. Download and compile it from:
http://github.com/SonarCommunity/sonar-scm-clearcase
Make sure to add sonar.scm.provider=clearcase into sonar.properties and re-run Sonar analysis.
The machine which runs Jenkins should have ClearCase. And make sure Jenkins can run cleartool command from console.
Thanks #Julien H. - SonarSource Team
For running SonarQube with JRE 7:
From SonarQube page:
The SonarQube Java analyser is able to analyse any kind of java source files whatever is the version of Java they comply to. But SonarQube analysis and SonarQube server require some specific versions of the JVM to be executed.
We can install many JRE versions on our machine. For SonarQube, just set the JRE variable before run it.
Example on Linux
export JRE_1.7=/opt/jre_1.7
export PATH=$JRE_1.7/bin:$PATH
java -version
/opt/sonar/sonarqube-5.1.1/bin/sonar.sh start

Unable to get sonar-fortify plugin configured with Jenkins and SonarQube

I have scoured the forums and cannot seem to quite understand the config for the fortify plug-in with Sonar.
I understand it simply builds a widget based on data from a previously generated .fpr file.
My setup:
Maven 3 project
Jenkins 1.606
SonarQube 5.0.1
Sonar-Fortify plug-in 2.0
Prerequisites:
.fpr file is in Jenkins workspace
Sonar is added to pom.xml
sonar-fortify-plug-in v2.0 added to pom.xml - (wasn’t sure this was needed or not)
Sonar server configured in Jenkins
sonar fortify plug-in v2.0 added to Sonar – (only see a dropdown to ‘enableReportLink’ under ‘Configure widgets’
should there be more config somewhere?
Questions:
Where should this property be set? Jenkins Sonar config, Sonar, pom file?
sonar-runner -Dsonar.fortify.reportPath=/path/to/project.fpr
Is that path to the .fpr file where it is within the Jenkins workspace?
The setup instructions on Github seem short and I feel I am missing something specific in my understanding.
Any help or direction to additional documentation is great appreciated.
First of all as documented version 2.0 can not be used anymore. Version 2.1 is going to be released soon. Vote for release will be started this week. Meanwhile you can:
download 2.1-SNAPSHOT version and copy it in extensions/plugins of your SonarQube server installation
restart server. The Fortify rules should be available in the page "Rules".
execute Fortify command "sourceanalyzer", independently from SonarQube. It generates a report file suffixed by .fpr.
execute a standard SonarQube analysis of your project by adding the property sonar.fortify.reportPath, for example:
mvn sonar:sonar -Dsonar.fortify.reportPath=/path/to/project.fpr
sonar-runner -Dsonar.fortify.reportPath=/path/to/project.fpr
If everything works, then you can automate these steps in Jenkins.

Sonar not picking up clover test results created by running maven in jenkins

I've been working on this all day and haven't been able to find a solution, so thought i'd turn to the stackoverflow community.
I have a server setup with Jenkins (version 1.454). It's configured to perform the build with Maven (version 3.0.4). The build command is as follows:
clean clover2:setup verify clover2:aggregate clover2:clover
Jenkins has the sonar plugin installed and configured. My sonar install (version 3) is on a different server to jenkins. After the build is completed, i can see the results on sonar (the basics of the build).
I have installed to sonar the clover plugin (sonar-clover-plugin-2.8.jar) manually by putting it into the 'extentions/plugins' folder. It appeared in sonar and I can configure it. I put in the license, version (3.1.4) and sonar.clover.reportPath as "target\site\clover\clover.xml".
When I run the build, it is successful as before, and I can see the basic results as before in Sonar, however, I cannot see any test code coverage results.
When I look at the maven build output I notice the following:
[INFO] Writing report to '/opt/jenkins/jobs/foo/workspace/target/site/clover/clover.xml'
and then near the bottom of the output:
[INFO] [15:08:36.586] Clover XML report not found
The following are also in my pom:
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.clover.reportPath>target\site\clover\clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>target\surefire-reports</sonar.surefire.reportsPath>
<sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
<sonar.clover.version>${clover.version}</sonar.clover.version>
When I look on the jenkins box, I can see that it has generated the clover.xml file (infact in my fiddling I have the clover plugin working on jenkins, so i can see the results there!).
I'm guessing at this stage that there is some issue with jenkins and sonar being on seperate boxes.
Any help would be appreciated!
Cheers.
After a lot more fiddling around, it appeared that I needed to change the following:
<sonar.clover.reportPath>${project.build.directory}/site/clover/clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
A good reference was the following:
all about pom variables

Resources