Sonar infinite loop in Jenkins - jenkins

I'm invoking a standalone sonar analysis under Jenkins with these versions:
Jenkins: 1.529
Jenkins Sonar Plugin: 2.1
Sonar: 3.5.1
Sonar is using the default h2 database. When I launch a build on Jenkins, it starts correctly but go in an infinite loop at the end of the following log, I let it run for 3 days without any result... Does somebody know where it comes from?
[SRC] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarForJenkins2.0/bin/sonar-runner ******** ******** -Dsonar.host.url=http://192.168.1.1:9000/sonar ******** ******** -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/Project/SRC -Dsonar.language=py -Dsonar.projectName=Project -Dsonar.projectVersion=1.0 -Dsonar.projectKey=Project -Dsonar.sources=server/apps/Project/
Runner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarForJenkins2.0/conf/sonar-runner.properties
Project configuration file: NONE
Runner version: 2.0
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
OS name: "Linux", version: "3.2.0-52-generic", arch: "amd64"
Default locale: "fr_FR", source code encoding: "UTF-8" (analysis is platform dependent)
Server: http://192.168.1.1:9000/sonar
Work directory: /var/lib/jenkins/workspace/Project/SRC/.sonar
15:29:43.167 INFO .s.b.b.BatchSettings - Load batch settings
15:29:43.260 INFO o.s.h.c.FileCache - User cache: /var/lib/jenkins/.sonar/cache
15:29:43.265 INFO atchPluginRepository - Install plugins
15:29:43.640 INFO .s.b.b.TaskContainer - ------------- Executing Project Scan
15:29:43.947 INFO b.b.JdbcDriverHolder - Install JDBC driver
15:29:43.949 INFO .b.ProjectExclusions - Apply project exclusions
15:29:43.952 WARN .c.p.DefaultDatabase - H2 database should be used for evaluation purpose only
15:29:43.952 INFO o.s.c.p.Database - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
15:29:44.020 INFO actDatabaseConnector - Initializing Hibernate
15:29:45.683 INFO .s.b.s.ScanContainer - ------------- Inspecting Project
15:29:45.687 INFO .b.b.ProjectSettings - Load module settings
15:29:45.895 INFO .s.b.ProfileProvider - Quality profile : [name=Sonar way,language=py]
15:29:45.908 INFO s.f.ExclusionFilters - Excluded tests:
15:29:45.908 INFO s.f.ExclusionFilters - **/package-info.java
15:29:45.929 INFO nPluginsConfigurator - Configure Maven plugins
15:29:45.954 INFO org.sonar.INFO - Compare to previous analysis (2013-09-09)
15:29:45.974 INFO org.sonar.INFO - Compare over 5 days (2013-09-04, analysis of 2013-09-03 07:57:38.902)
15:29:45.980 INFO org.sonar.INFO - Compare over 30 days (2013-08-10, analysis of 2013-08-12 19:34:45.97)
15:29:46.057 INFO s.f.FileSystemLogger - Base dir: /var/lib/jenkins/workspace/Project/SRC
15:29:46.057 INFO s.f.FileSystemLogger - Working dir: /var/lib/jenkins/workspace/Project/SRC/.sonar
15:29:46.057 INFO s.f.FileSystemLogger - Source dirs: /var/lib/jenkins/workspace/Project/SRC/server/apps/Project
15:29:46.057 INFO s.f.FileSystemLogger - Source encoding: UTF-8, default locale: fr_FR
15:29:46.096 INFO p.PhasesTimeProfiler - Sensor org.sonar.plugins.python.PythonSourceImporter#549b6976...
15:29:46.825 INFO p.PhasesTimeProfiler - Sensor org.sonar.plugins.python.PythonSourceImporter#549b6976 done: 729 ms
15:29:46.825 INFO p.PhasesTimeProfiler - Sensor PythonSquidSensor...
15:29:48.152 INFO p.PhasesTimeProfiler - Sensor PythonSquidSensor done: 1327 ms
15:29:48.153 INFO p.PhasesTimeProfiler - Sensor PythonXunitSensor...
15:29:48.160 INFO p.PhasesTimeProfiler - Sensor PythonXunitSensor done: 7 ms
15:29:48.161 INFO p.PhasesTimeProfiler - Sensor PythonCoverageSensor...
15:29:48.161 INFO p.PhasesTimeProfiler - Sensor PythonCoverageSensor done: 0 ms
15:29:48.161 INFO p.PhasesTimeProfiler - Sensor CpdSensor...
15:29:48.161 INFO o.s.p.cpd.CpdSensor - SonarBridgeEngine is used
15:29:48.169 INFO s.p.c.i.IndexFactory - Cross-project analysis disabled
15:29:48.497 INFO p.PhasesTimeProfiler - Sensor CpdSensor done: 336 ms
15:29:48.497 INFO p.PhasesTimeProfiler - Sensor ProfileSensor...
15:29:48.522 INFO p.PhasesTimeProfiler - Sensor ProfileSensor done: 25 ms
15:29:48.523 INFO p.PhasesTimeProfiler - Sensor ProfileEventsSensor...
15:29:48.539 INFO p.PhasesTimeProfiler - Sensor ProfileEventsSensor done: 17 ms
15:29:48.540 INFO p.PhasesTimeProfiler - Sensor ProjectLinksSensor...
15:29:48.543 INFO p.PhasesTimeProfiler - Sensor ProjectLinksSensor done: 3 ms
15:29:48.543 INFO p.PhasesTimeProfiler - Sensor VersionEventsSensor...
15:29:48.551 INFO p.PhasesTimeProfiler - Sensor VersionEventsSensor done: 8 ms
15:29:48.984 INFO p.PhasesTimeProfiler - Execute decorators...
15:29:51.132 INFO s.c.c.ScanGraphStore - Persist graphs of components
15:29:51.193 INFO .b.p.UpdateStatusJob - ANALYSIS SUCCESSFUL, you can browse http://192.168.1.1:9000/sonar
15:29:51.194 INFO b.p.PostJobsExecutor - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
15:29:51.213 INFO b.p.PostJobsExecutor - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
15:29:51.223 INFO .p.d.p.KeepOneFilter - -> Keep one snapshot per day between 2013-08-26 and 2013-09-08
15:29:51.225 INFO .p.d.p.KeepOneFilter - -> Keep one snapshot per week between 2012-09-10 and 2013-08-26
15:29:51.227 INFO .p.d.p.KeepOneFilter - -> Keep one snapshot per month between 2008-09-15 and 2012-09-10
15:29:51.230 INFO .d.p.DeleteAllFilter - -> Delete data prior to: 2008-09-15
15:29:51.232 INFO o.s.c.purge.PurgeDao - -> Clean Project [id=1]
15:29:51.236 INFO o.s.c.purge.PurgeDao - <- Clean snapshot 39274

The H2 database is for testing purpose only. Could you please move to a "real" database? See http://docs.codehaus.org/display/SONAR/Requirements.

Related

Code coverage for Manual Regression using sonar and jacoco

I am trying to generate code coverage for webapp for manual testing using jacoco and sonar.
I am able to generate jacoco.exec file by modifying the catalina.bat in following way:
SET JACOCO=-javaagent:\jacoco-0.7.5.201505241946\lib\jacocoagent.jar=destfile=C:\jacoco.exec,append=true,includes=*
set JAVA_OPTS=%JAVA_OPTS% %JACOCO%
I then copy the jacoco.exec file to a target folder inside sonarcube and run ant sonar. The build.xml has following entries:
<!-- The following properties are required to use JaCoCo: -->
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="target/jacoco.exec" />
<!-- Define the SonarQube target -->
<target name="sonar">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
<classpath path="../apache-ant-1.9.6/lib/sonar-ant-task-2.3.jar"/>
</taskdef>
<!-- Execute the SonarQube analysis -->
<sonar:sonar/>
</target>
</project>
The output I get from ant if following. I don't see any coverage in the report at the url
http://localhost:9000/dashboard/index/org.codehaus.sonar:example-java-ant
Am I missing something?
c:\sonarqube>ant sonar
Buildfile: c:\sonarqube\build.xml
sonar:
[sonar:sonar] Apache Ant(TM) version 1.9.6 compiled on June 29 2015
[sonar:sonar] SonarQube Ant Task version: 2.3
[sonar:sonar] Loaded from: file:/C:/apache-ant-1.9.6/lib/sonar-ant-task-2.3.jar
[sonar:sonar] INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
[sonar:sonar] INFO: Work directory: c:\sonarqube\.sonar
[sonar:sonar] INFO: SonarQube Server 5.2
[sonar:sonar] 17:18:52.370 INFO - Load global repositories
[sonar:sonar] 17:18:52.959 INFO - Load global repositories (done) | time=588ms
[sonar:sonar] 17:18:53.034 INFO - User cache: C:\Users\Administrator\.sonar\cache
[sonar:sonar] 17:18:53.932 INFO - Load plugins index
[sonar:sonar] 17:18:53.952 INFO - Load plugins index (done) | time=20ms
[sonar:sonar] 17:18:54.677 INFO - Process project properties
[sonar:sonar] 17:18:57.381 INFO - Load project repositories
[sonar:sonar] 17:18:57.493 INFO - Load project repositories (done) | time=112ms
[sonar:sonar] 17:18:57.535 INFO - Apply project exclusions
[sonar:sonar] 17:18:57.667 INFO - Load quality profiles
[sonar:sonar] 17:18:57.983 INFO - Load quality profiles (done) | time=315ms
[sonar:sonar] 17:18:58.039 INFO - Load active rules
[sonar:sonar] 17:19:00.610 INFO - Load active rules (done) | time=2571ms
[sonar:sonar] 17:19:00.636 WARN - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[sonar:sonar] 17:19:00.797 WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.
scm.provider to define SCM of your project.
[sonar:sonar] 17:19:00.800 INFO - Publish mode
[sonar:sonar] 17:19:00.805 INFO - ------------- Scan Simple Java Project analyzed with the SonarQube Ant Task
[sonar:sonar] 17:19:01.844 INFO - Language is forced to java
[sonar:sonar] 17:19:01.887 INFO - Load server rules
[sonar:sonar] 17:19:02.373 INFO - Load server rules (done) | time=486ms
[sonar:sonar] 17:19:02.755 INFO - Base dir: c:\sonarqube
[sonar:sonar] 17:19:02.756 INFO - Working dir: c:\sonarqube\.sonar
[sonar:sonar] 17:19:02.781 INFO - Source paths: src
[sonar:sonar] 17:19:02.786 INFO - Source encoding: windows-1252, default locale: en_US
[sonar:sonar] 17:19:02.787 INFO - Index files
[sonar:sonar] 17:19:02.854 INFO - 0 files indexed
[sonar:sonar] 17:19:02.857 INFO - Quality profile for java: Sonar way
[sonar:sonar] 17:19:02.999 INFO - Sensor Lines Sensor
[sonar:sonar] 17:19:03.005 INFO - Sensor Lines Sensor (done) | time=6ms
[sonar:sonar] 17:19:03.006 INFO - Sensor QProfileSensor
[sonar:sonar] 17:19:03.095 INFO - Sensor QProfileSensor (done) | time=89ms
[sonar:sonar] 17:19:03.096 INFO - Sensor SCM Sensor
[sonar:sonar] 17:19:03.097 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
[sonar:sonar] 17:19:03.100 INFO - Sensor SCM Sensor (done) | time=4ms
[sonar:sonar] 17:19:03.100 INFO - Sensor Code Colorizer Sensor
[sonar:sonar] 17:19:03.106 INFO - Sensor Code Colorizer Sensor (done) | time=6ms
[sonar:sonar] 17:19:03.107 INFO - Sensor CPD Sensor
[sonar:sonar] 17:19:03.108 INFO - JavaCpdEngine is used for java
[sonar:sonar] 17:19:03.110 INFO - Sensor CPD Sensor (done) | time=3ms
[sonar:sonar] 17:19:03.304 INFO - Analysis reports generated in 192ms, dir size=5 KB
[sonar:sonar] 17:19:03.320 INFO - Analysis reports compressed in 15ms, zip size=2 KB
[sonar:sonar] 17:19:03.758 INFO - Analysis reports sent to server in 424ms
[sonar:sonar] 17:19:03.762 INFO - ANALYSIS SUCCESSFUL, you can browse
Looking at log of analysis we cannot see any JaCoCo sensor executed. JaCoCo sensor is executed only if you have java file in your analysis which you don't as you can see per 0 files indexed line in your log.
To explain this behaviour you have to understand that JaCoCo sensor will only report coverage on files indexed so if there are no java files, there is no point to execute it.
So to report and compute coverage you would have to import a coverage report related to some source files you analyze in your project.

Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for

I will need your help please.
This is the context, I'm trying to set up a Continous Integration plateform, for specifc needs, and this is my Configuration, all in the same machine(Windows 7 ):
SonarQube 5.1 (I tried both internal and external databases)
SonarQube runner 2.4
PHP plugin for Sonar
Jenkins 1.6
SonarQube plugin for Jenkins (I'have already done all of the Sonarqube config in Jenkins)
I created a specific Job for PHP (Which is a local folder in my file system)(I configured the build section of Jenkins bu adding Standalone SonarQube Analysis, with the specific Path to projeetc proporties which point to my sonar-project.properties behind )
sonar.projectKey=my:project
sonar.projectName=PHP project analyzed with the SonarQube Runner reusing PHPUnit reports
sonar.projectVersion=1.0
sonar.sources=userthing,test sonar.tests=test sonar.language=php sonar.sourceEncoding=UTF-8 # Reusing PHPUnit reports #sonar.php.coverage.reportPath=reports/phpunit.coverage.xml #sonar.php.tests.reportPath=reports/phpunit.xml
When I launch a build from Jenkins I have this error :
NFO: Work directory: C:\Users\user\.jenkins\jobs\test projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:13:10.295 INFO - Load global repositories
14:13:10.372 INFO - Load global repositories (done) | time=78ms
14:13:10.374 INFO - Server id: 20151028133512
14:13:10.374 INFO - User cache: C:\Users\user\.sonar\cache
14:13:10.379 INFO - Install plugins
14:13:10.706 INFO - Install JDBC driver
14:13:10.710 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:13:11.247 INFO - Initializing Hibernate
14:13:12.106 ERROR - Invalid value of sonar.tests for my:project
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.131s
Final Memory: 6M/20M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for 'my:project' (base directory = C:\Users\user\.jenkins\jobs\test projet\workspace)
at org.sonar.batch.scan.ProjectReactorBuilder.checkExistenceOfPaths(ProjectReactorBuilder.java:427)
at org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:334)
at org.sonar.batch.scan.ProjectReactorBuilder.defineRootProject(ProjectReactorBuilder.java:163)
at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:110)
at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:86)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Lancer une analyse SonarQube autonome' marked build as failure
Finished: FAILURE
I follow those steps to identify the root concern:
I created manually sonar-project.properties.
Lunch sonar-runner.bat directly from my php folder, => then it works perfectly I have all the metric.
I'm sure that the root cause is Jenkins, but I don't know exactly what I'm missing.
Even if some times everything seems to work fine, I got this message from stacktrace
0 file indexed
:
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\DevTools\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\user\Desktop\Exemple de projet PHPUNIT\sonar-project.properties
INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:55:20.977 INFO - Load global repositories
14:55:21.040 INFO - Load global repositories (done) | time=63ms
14:55:21.040 INFO - Server id: 20151028133512
14:55:21.040 INFO - User cache: C:\Users\user\.sonar\cache
14:55:21.040 INFO - Install plugins
14:55:21.390 INFO - Install JDBC driver
14:55:21.390 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:55:21.918 INFO - Initializing Hibernate
14:55:22.858 INFO - Load project repositories
14:55:23.030 INFO - Load project repositories (done) | time=172ms
14:55:23.030 INFO - Load project settings
14:55:23.326 INFO - Load technical debt model
14:55:23.358 INFO - Apply project exclusions
14:55:23.498 WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
14:55:23.498 INFO - ------------- Scan My Sonar Analyses for PHP project
14:55:23.498 INFO - Load module settings
14:55:23.576 INFO - Language is forced to php
14:55:23.576 INFO - Load rules
14:55:23.864 INFO - Base dir: C:\Users\user\.jenkins\jobs\projet\workspace
14:55:23.864 INFO - Working dir: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
14:55:23.864 INFO - Source paths: .
14:55:23.864 INFO - Source encoding: UTF-8, default locale: fr_FR
14:55:23.864 INFO - Index files
14:55:23.866 INFO - **0 files indexed******************************
14:55:23.866 INFO - Quality profile for php: Sonar way
14:55:24.095 INFO - Sensor Lines Sensor
14:55:24.095 INFO - Sensor Lines Sensor (done) | time=0ms
14:55:24.095 INFO - Sensor QProfileSensor
14:55:24.105 INFO - Sensor QProfileSensor (done) | time=10ms
14:55:24.105 INFO - Sensor InitialOpenIssuesSensor
14:55:24.120 INFO - Sensor InitialOpenIssuesSensor (done) | time=15ms
14:55:24.120 INFO - Sensor ProjectLinksSensor
14:55:24.128 INFO - Sensor ProjectLinksSensor (done) | time=8ms
14:55:24.128 INFO - Sensor VersionEventsSensor
14:55:24.133 INFO - Sensor VersionEventsSensor (done) | time=5ms
14:55:24.133 INFO - Sensor SCM Sensor
14:55:24.133 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
14:55:24.133 INFO - Sensor SCM Sensor (done) | time=0ms
14:55:24.133 INFO - Sensor CPD Sensor
14:55:24.133 INFO - DefaultCpdEngine is used for php
14:55:24.133 INFO - Sensor CPD Sensor (done) | time=0ms
14:55:24.133 INFO - No quality gate is configured.
14:55:24.163 INFO - Compare to previous analysis (2015-10-28)
14:55:24.165 INFO - Compare over 30 days (2015-09-28, analysis of Wed Oct 28 14:39:55 CET 2015)
14:55:24.267 INFO - Execute decorators...
14:55:24.372 INFO - Store results in database
14:55:24.425 INFO - Analysis reports generated in 35ms, dir size=2 KB
14:55:24.435 INFO - Analysis reports compressed in 10ms, zip size=2 KB
14:55:24.459 INFO - Analysis reports sent to server in 23ms
14:55:24.460 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/projet
14:55:24.460 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3.851s
Final Memory: 13M/113M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS
It seems like his enable to index files that I have in my php folder.
Thanks in advance for your help!
I found the root cause, as I suggested in my last comment Jenkis is the root concern, because, I wasn't aware how Jenkins, build non source Controle Projects.
In fact you have to follow those steps in order to copy your projet into Jenkis workspace:
Build the Project at least once, (it will fail), but Jenkins will
create the structure jenkins/workspace/PROJECTNAME/
Copy the project files to jenkins/workspace/PROJECTNAME/
Build again and configure appropriately
For more information in the subject, I will suggest that you look jenkins docs:Builds for Non-Source Control Projects

SonarQube project not updating from Sonar Runner

I've provisioned three projects, two of which update as expected each time Jenkins deploys to the dev environment. However, while the third job populates with the initial results, each subsequent run does not update the project despite successful SonarRunner execution. (I've scrubbed some of the names and paths).
Here is the failing job project file:
# required metadata
sonar.projectKey=xxxxxxx
sonar.projectName=xxxxxxx
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=src
# paths to exclude
#sonar.exclusions=
sonar.scm.disabled=true
sonar.javascript.mode=skip
sonar.css.mode=skip
# Encoding of the source code
sonar.sourceEncoding=UTF-8
Here is the console output from Jenkins:
SonarQube Runner 2.4
Java 1.7.0_71 Oracle Corporation (64-bit)
Linux 2.6.32-504.3.3.el6.x86_64 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: xxxxxxxx/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: xxxxxxx/workspace/.sonar
INFO: SonarQube Server 5.1
12:29:29.558 INFO - Load global repositories
12:29:29.784 INFO - Load global repositories (done) | time=228ms
12:29:29.786 INFO - Server id: 20150522113240
12:29:29.788 INFO - User cache: /var/lib/jenkins/.sonar/cache
12:29:29.797 INFO - Install plugins
12:29:30.091 INFO - Install JDBC driver
12:29:30.112 INFO - Create JDBC datasource for jdbc:mysql://xxxxxxx/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
12:29:31.619 INFO - Initializing Hibernate
12:29:33.037 INFO - Load project repositories
12:29:34.129 INFO - Load project repositories (done) | time=1092ms
12:29:34.130 INFO - Load project settings
12:29:34.834 INFO - Load technical debt model
12:29:34.863 INFO - Apply project exclusions
12:29:36.001 INFO - ------------- Scan www.XXXXXXXXX.com-XXXXXXXX
12:29:36.005 INFO - Load module settings
12:29:36.214 INFO - Load rules
12:29:37.422 INFO - Base dir: xxxxx/workspace
12:29:37.422 INFO - Working dir: xxxxx.sonar
12:29:37.422 INFO - Source paths: src
12:29:37.423 INFO - Source encoding: UTF-8, default locale: en_US
12:29:37.423 INFO - Index files
12:29:38.342 INFO - 254 files indexed
12:29:43.048 INFO - Quality profile for java: Sonar way
12:29:43.048 INFO - Quality profile for xml: Sonar way
12:29:43.524 WARN - ----------------------------------------------------------------
12:29:43.524 WARN - Sonargraph: Skipping project xxxxx, since no Sonargraph rules are activated in current SonarQube quality profile.
12:29:43.524 WARN - ----------------------------------------------------------------
12:29:43.526 INFO - JIRA issues sensor will not run as some parameters are missing.
12:29:43.541 INFO - Sensor JavaSquidSensor
12:29:44.015 INFO - Java Main Files AST scan...
12:29:44.017 INFO - 238 source files to be analyzed
12:29:55.279 INFO - 238/238 source files analyzed
12:29:55.278 INFO - Java Main Files AST scan done: 11263 ms
12:29:55.279 WARN - Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor#7cd07967, org.sonar.java.checks.UnusedPrivateMethodCheck#43b7ee4b, org.sonar.java.checks.RedundantThrowsDeclarationCheck#607da0a8 are disabled.
12:29:55.280 INFO - Java Test Files AST scan...
12:29:55.280 INFO - 0 source files to be analyzed
12:29:55.280 INFO - Java Test Files AST scan done: 0 ms
12:29:55.280 INFO - 0/0 source files analyzed
12:29:55.466 INFO - Sensor JavaSquidSensor (done) | time=11925ms
12:29:55.467 INFO - Sensor Lines Sensor
12:29:55.501 INFO - Sensor Lines Sensor (done) | time=34ms
12:29:55.501 INFO - Sensor QProfileSensor
12:29:55.505 INFO - Sensor QProfileSensor (done) | time=4ms
12:29:55.506 INFO - Sensor InitialOpenIssuesSensor
12:30:29.395 INFO - Sensor InitialOpenIssuesSensor (done) | time=33889ms
12:30:29.395 INFO - Sensor ProjectLinksSensor
12:30:29.404 INFO - Sensor ProjectLinksSensor (done) | time=9ms
12:30:29.404 INFO - Sensor VersionEventsSensor
12:30:29.427 INFO - Sensor VersionEventsSensor (done) | time=23ms
12:30:29.427 INFO - Sensor XmlSensor
12:31:14.500 INFO - Sensor XmlSensor (done) | time=45073ms
12:31:14.500 INFO - Sensor LineCountSensor
12:31:15.041 INFO - Sensor LineCountSensor (done) | time=541ms
12:31:15.041 INFO - Sensor SurefireSensor
12:31:15.728 INFO - Sensor SurefireSensor (done) | time=687ms
12:31:15.729 INFO - Sensor SCM Sensor
12:31:15.729 INFO - SCM Sensor is disabled
12:31:15.729 INFO - Sensor SCM Sensor (done) | time=0ms
12:31:15.729 INFO - Sensor CPD Sensor
12:31:15.729 INFO - JavaCpdEngine is used for java
12:31:15.731 INFO - Cross-project analysis disabled
12:31:16.474 INFO - DefaultCpdEngine is used for xml
12:31:16.476 INFO - Sensor CPD Sensor (done) | time=747ms
12:31:16.477 INFO - No quality gate is configured.
12:31:16.520 INFO - Compare to previous analysis (2015-05-22)
12:31:16.524 INFO - Compare over 30 days (2015-04-26, analysis of Fri May 22 11:08:22 CDT 2015)
12:31:17.192 INFO - Execute decorators...
12:32:58.147 INFO - Store results in database
12:33:12.805 INFO - Analysis reports generated in 4585ms, dir size=64 MB
12:33:14.429 INFO - Analysis reports compressed in 1624ms, zip size=9 MB
12:33:16.335 INFO - Analysis reports sent to server in 1905ms
12:33:16.336 INFO - ANALYSIS SUCCESSFUL, you can browse xxxxxx
12:33:16.336 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3:47.493s
Final Memory: 37M/2167M
I also had some issue last time.
I use community version, so I could not manage the pull request and branch name.
I installed locally, so every time you want to update the code, you must run manually sonar-scanner.bat xxxxx
And new codes menu will update automatically after you run that command.

Sonar runner codenarc sensor ignore violation from Codenarc

I have grails project with CodeNarc Plugin installed and generated xml report. Installed and configured SonarQube with following configurations and versions:
Grails 2.3.7
SonarQube server- 4.5
SonarQube Runner- 2.4
CodeNarc Plugin- 0.22
Sonar-project.properties file contains
#sonar-runner.properties
sonar.projectKey=key
sonar.projectName=Project Name
sonar.projectVersion=1.0
sonar.sources=src, grails-app/services, grails-app/controllers, grails-app/domain
sonar.tests=test/
sonar.language=grvy
sonar.sourceEncoding=UTF-8
sonar.groovy.codenarc.reportPath=target/codenarc/codeNarcXMLReport.xml
Generated CodeNarc XML report and added its report path in file.
Sonar runner analyse project but with zero issues
Sonar runner unable to index resources and throws warning for CodeNarc rules violations.
SonarQube Runner 2.4
Java 1.7.0_21 Oracle Corporation (64-bit)
Linux 3.11.0-26-generic amd64
INFO: Runner configuration file: /media/Others/softwares/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /media/Others/repo/project/sonar-project.properties
INFO: Default locale: "en_IN", source code encoding: "UTF-8"
INFO: Work directory: /media/Others/repo/project/./.sonar
INFO: SonarQube Server 4.5
11:20:57.146 INFO - Load global referentials...
11:20:57.356 INFO - Load global referentials done: 213 ms
11:20:57.367 INFO - User cache: /home/.sonar/cache
11:20:57.378 INFO - Install plugins
11:20:57.680 INFO - Install JDBC driver
11:20:57.688 INFO - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
11:20:59.590 INFO - Initializing Hibernate
11:21:01.310 INFO - Load project referentials...
11:21:02.342 INFO - Load project referentials done: 1032 ms
11:21:02.342 INFO - Load project settings
11:21:03.193 INFO - Loading technical debt model...
11:21:03.218 INFO - Loading technical debt model done: 25 ms
11:21:03.222 INFO - Apply project exclusions
11:21:03.598 INFO - ------------- Scan project
11:21:03.603 INFO - Load module settings
11:21:04.228 INFO - Language is forced to grvy
11:21:04.230 INFO - Loading rules...
11:21:05.224 INFO - Loading rules done: 994 ms
11:21:05.260 INFO - Configure Maven plugins
11:21:05.537 INFO - Compare to previous analysis (2014-12-23)
11:21:05.557 INFO - Compare over 30 days (2014-11-23, analysis of 2014-11-10 17:20:47.0)
11:21:05.578 INFO - Compare to previous version (2014-10-30)
11:21:05.636 INFO - Loaded quality gate 'SonarQube way'
11:21:05.817 INFO - Base dir: /media/Others/repo/project/.
11:21:05.817 INFO - Working dir: /media/Others/repo/project/./.sonar
11:21:05.818 INFO - Source paths: src, grails-app/services, grails-app/controllers, grails-app/domain
11:21:05.818 INFO - Test paths: test
11:21:05.818 INFO - Source encoding: UTF-8, default locale: en_IN
11:21:05.818 INFO - Index files
11:21:06.276 INFO - 226 files indexed
11:21:44.020 INFO - Quality profile for grvy: Sonar way
11:21:44.404 INFO - Sensor QProfileSensor...
11:21:44.416 INFO - Sensor QProfileSensor done: 13 ms
11:21:44.416 INFO - Sensor CodeNarc...
11:21:44.593 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.594 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.595 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.596 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.599 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#221
[resource=org.sonar.api.resources.File#4254e18d[key=<null>,deprecatedKey=grails-app/controllers/LoginController.groovy,path=<null>,
dir=grails-app/controllers,filename=LoginController.groovy,language=<null>],rule=Rule[id=427,name=Catch
Exception,key=org.codenarc.rule.exceptions.CatchExceptionRule,configKey=CatchException,plugin=grvy,severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=The type Exception should not be caught,severity=<null>,lineId=93,cost=<null>,createdAt=<null>,switchedOff=false,
checksum=<null>,isNew=false,isManual=false,permanentId=<null>,personId=<null>]
11:21:44.602 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#5e3666d9[resource=org.sonar.api.resources.File#459a60e1[key=<null>,
deprecatedKey=grails-app/controllers/LoginController.groovy,path=<null>,dir=grails-app/controllers,filename=LoginController.groovy,language=<null>],rule=Rule[id=431,name=Unused Method Parameter,key=org.codenarc.rule.unused.UnusedMethodParameterRule,configKey=UnusedMethodParameter,
plugin=grvy,severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=Violation in class LoginController. Method parameter [newSignup] is never referenced in the method authComplete of class LoginController,severity=<null>,lineId=100,cost=<null>,createdAt=<null>,
switchedOff=false,checksum=<null>,isNew=false,isManual=false,permanentId=<null>,personId=<null>]
...
...
...
11:21:45.661 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#6c95883d[resource=org.sonar.api.resources.File#4d23947c[key=<null>,deprecatedKey=test/unit/project/HomeControllerTests.groovy,
path=<null>,dir=test/unit/project,filename=HomeControllerTests.groovy,language=<null>],rule=Rule[id=643,name=Empty Method,key=org.codenarc.rule.basic.EmptyMethodRule,configKey=EmptyMethod,plugin=grvy,
severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=Violation in class HomeControllerTests. The method tearDown is both empty and not marked with #Override,severity=<null>,lineId=121,cost=<null>,createdAt=<null>,switchedOff=false,checksum=<null>,
isNew=false,isManual=false,permanentId=<null>,personId=<null>]
11:21:45.661 INFO - Sensor CodeNarc done: 1245 ms
11:21:45.662 INFO - Sensor GroovySensor...
11:21:48.552 INFO - GMetrics completed: 1493ms
11:21:49.580 INFO - GMetrics completed: 941ms
11:21:51.285 INFO - GMetrics completed: 1601ms
11:21:51.561 INFO - GMetrics completed: 156ms
11:21:52.081 INFO - GMetrics completed: 488ms
11:21:52.167 INFO - Sensor GroovySensor done: 6505 ms
11:21:52.167 INFO - Sensor Groovy CoberturaSensor...
11:21:52.167 INFO - Analyzing Cobertura report: target/test-reports/cobertura/coverage.xml
11:21:52.955 INFO - Sensor Groovy CoberturaSensor done: 788 ms
11:21:52.956 INFO - Sensor ScmActivitySensor...
11:21:52.956 INFO - Trying to guess scm provider from project layout...
11:21:52.956 INFO - Found SCM type: git
11:21:52.958 INFO - Retrieve SCM blame information with encoding UTF-8...
11:21:55.580 INFO - Retrieve SCM blame information with encoding UTF-8 done: 2622 ms
11:21:55.581 INFO - Sensor ScmActivitySensor done: 2625 ms
11:21:55.585 INFO - Sensor InitialOpenIssuesSensor...
11:21:55.597 INFO - Sensor InitialOpenIssuesSensor done: 11 ms
11:21:55.597 INFO - Sensor ProjectLinksSensor...
11:21:55.607 INFO - Sensor ProjectLinksSensor done: 10 ms
11:21:55.608 INFO - Sensor VersionEventsSensor...
11:21:55.733 INFO - Sensor VersionEventsSensor done: 125 ms
11:21:55.733 INFO - Sensor FileHashSensor...
11:21:55.743 INFO - Sensor FileHashSensor done: 9 ms
11:21:55.743 INFO - Sensor CPD Sensor (wrapped)...
11:21:55.743 INFO - DefaultCpdEngine is used for grvy
11:21:55.751 INFO - Cross-project analysis disabled
11:21:56.330 INFO - Sensor CPD Sensor (wrapped) done: 587 ms
11:21:56.918 INFO - Execute decorators...
11:22:01.785 INFO - Store results in database
11:22:10.256 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/project
11:22:10.392 INFO - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
11:22:10.393 INFO - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
11:22:10.461 INFO - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
11:22:10.473 INFO - -> Keep one snapshot per day between 2014-11-25 and 2014-12-22
11:22:10.475 INFO - -> Keep one snapshot per week between 2013-12-24 and 2014-11-25
11:22:10.475 INFO - -> Keep one snapshot per month between 2009-12-29 and 2013-12-24
11:22:10.476 INFO - -> Delete data prior to: 2009-12-29
11:22:10.482 INFO - -> Clean project [id=225]
11:22:10.487 INFO - <- Clean snapshot 8702
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 1:15.303s
Final Memory: 26M/737M
INFO: ------------------------------------------------------------------------
I have installed all necessary plugins in SonarQube Server
After all configuration why these rules are getting ignored and zero issues generated for project ?
I have the same problem with getting ignored issues generated from codenarc report.
I found similar topic in sonarqube Nabble service that probably removing from codenarc report from path attributes every "grails-app/domain/", "grails-app/services/" etc. will resolve the problem, but this is only the source of the problem, there is nothing about how to do it automatically.
Below I attached the link to this post in the article.
http://sonarqube.15.x6.nabble.com/No-Issues-and-code-coverage-for-groovy-in-multi-language-project-with-SonarQube-4-2-tp5023761p5023806.html
We had this same problem. The issue surrounded SonarQube not being able to process violations in the CodeNarc report XML file. As shared in a previous answer, entries in the XML file that looks like the following:
...
<Package path='grails-app' totalFiles='54' filesWithViolations='46' priority1='10' priority2='92' priority3='610'/>
<Package path='grails-app/controllers' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='grails-app/controllers/com' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='grails-app/controllers/com/...' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
...
will cause them to be ignored. As a work-around, we wrote a groovy script that strips out the "grails-app" and "grails-app/<folder>/" from the report file so that it looks like the following:
...
<Package path='com' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='com/...' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
...
The script is run during our Jenkins builds after the report is generated and before the Sonar analysis is performed.
We are running SonarQube 4.5.1 (LTS) and using the version 1.0.1 of the Groovy plugin.

Sonar-runner not importing cobertura coverage.xml report for Groovy/Grails project

I have generated coverage reports with cobertura outside of sonar and would like to "reuse" them and import them into Sonar. Is this possible.
Sonar 3.73
Sonar-Runner 2.3
sonar.projectKey=org.me:artifactname
sonar.projectName=Project Name
sonar.projectVersion=1.0
sonar.sources=src/groovy, grails-app
sonar.language=grvy
sonar.sourceEncoding=UTF-8
sonar.tests=test/unit
sonar.dynamicAnalysis=reuseReports
sonar.core.codeCoveragePlugin=cobertura
sonar.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
sonar.surefire.reportsPath=target/test-reports
sonar.grvy.coveragePlugin=cobertura
The coverage.xml file does exist and is in that path. I've checked it 100 times.
The Unit Test success info is filled out in sonar but the Unit Tests Coverage is a dash, and blank.
Everything else is filled in, complexity, lines of code....
Here's part of the output.
15:47:10.837 INFO - Load module settings
15:47:11.085 INFO - Quality profile : [name=Sonar way,language=grvy]
15:47:11.103 INFO - Excluded tests:
15:47:11.104 INFO - **/package-info.java
15:47:11.143 INFO - Configure Maven plugins
15:47:11.176 INFO - Compare to previous analysis (2013-12-20)
15:47:11.210 INFO - Compare over 30 days (2013-11-20, analysis of 2013-12-19 15:41:26.0)
15:47:11.219 INFO - Compare to previous version
15:47:11.648 INFO - Base dir: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace
15:47:11.648 INFO - Working dir: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/.sonar
15:47:11.648 INFO - Source dirs: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/src/groovy
15:47:11.648 INFO - Source encoding: UTF-8, default locale: en_US
15:47:11.662 INFO - Sensor GroovySourceImporter...
15:47:11.761 INFO - Sensor GroovySourceImporter done: 99 ms
15:47:11.761 INFO - Sensor CpdSensor...
15:47:11.761 INFO - SonarBridgeEngine is used
15:47:11.763 INFO - Cross-project analysis disabled
15:47:11.840 INFO - Sensor CpdSensor done: 79 ms
15:47:11.841 INFO - Sensor GroovySensor...
15:47:12.855 INFO - GMetrics completed: 591ms
15:47:12.879 INFO - Sensor GroovySensor done: 1038 ms
15:47:12.879 INFO - Sensor Groovy SurefireSensor...
15:47:12.881 INFO - parsing /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/target/test-reports
15:47:12.978 INFO - Sensor Groovy SurefireSensor done: 99 ms
15:47:12.978 INFO - Sensor InitialOpenIssuesSensor...
15:47:12.983 INFO - Sensor InitialOpenIssuesSensor done: 5 ms
15:47:12.983 INFO - Sensor ProfileSensor...
15:47:12.993 INFO - Sensor ProfileSensor done: 10 ms
15:47:12.993 INFO - Sensor ProfileEventsSensor...
15:47:13.019 INFO - Sensor ProfileEventsSensor done: 26 ms
15:47:13.019 INFO - Sensor ProjectLinksSensor...
15:47:13.028 INFO - Sensor ProjectLinksSensor done: 9 ms
15:47:13.029 INFO - Sensor VersionEventsSensor...
15:47:13.041 INFO - Sensor VersionEventsSensor done: 12 ms
15:47:13.041 INFO - Sensor org.sonar.plugins.artifactsize.ArtifactSizeSensor#52156251...
15:47:13.041 INFO - The file null does not exist
15:47:13.041 INFO - Sensor org.sonar.plugins.artifactsize.ArtifactSizeSensor#52156251 done: 0 ms
15:47:13.470 INFO - Execute decorators...
Thoughts.
Try using the absolute path for cobetura reportpath properties. For windows box you can try using the below
sonar.cobertura.reportPath=\\target\\test-reports\\cobertura\\coverage.xml
Try adding this block to your BuildConfig.groovy
coverage {
xml = true
}
You need to use the right property key for specifying the coverage xml report path:
sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml

Resources