2014-05-21 23 views
5

Ho un lavoro Jenkins che esegue SonarRunner su un progetto Maven composto da diversi moduli. La compilazione fallisce quando configuro SonarRunner per importare i report di copertura di Cobertura.org.sonar.api.utils.SonarException: impossibile aggiungere due volte la stessa misura su org.sonar.api.resources.File

SonarQube Runner 2.4 
Java 1.7.0_55 Oracle Corporation (64-bit) 
Windows 7 6.1 amd64 
INFO: Error stacktraces are turned on. 
INFO: Runner configuration file: C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\Sonar_Runner\conf\sonar-runner.properties 
INFO: Project configuration file: NONE 
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent) 
INFO: Work directory: C:\Jenkins\workspace\Sprint3\Application\.sonar 
INFO: SonarQube Server 4.3 
11:07:44.407 INFO - Load batch settings 
11:07:44.609 INFO - User cache: C:\.sonar\cache 
11:07:44.625 INFO - Install plugins 
11:07:44.765 INFO - Install JDBC driver 
11:07:44.781 WARN - H2 database should be used for evaluation purpose only 
11:07:44.781 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar 
11:07:45.951 INFO - Initializing Hibernate 
11:07:47.885 INFO - Load project settings 
11:07:47.963 INFO - Apply project exclusions 
11:07:48.229 INFO - ------------- Scan JmsUtils 
11:07:48.229 INFO - Load module settings 
11:07:49.508 INFO - Loading technical debt model... 
11:07:49.523 INFO - Loading technical debt model done: 15 ms 
11:07:49.523 INFO - Loading rules... 
11:07:49.789 INFO - Loading rules done: 266 ms 
11:07:49.804 INFO - Configure Maven plugins 
11:07:49.976 INFO - Compare to previous analysis (2014-05-21) 
11:07:50.007 INFO - Compare over 30 days (2014-04-21, analysis of 2014-05-08 15:55:35.699) 
11:07:50.007 INFO - No quality gate is configured. 
11:07:50.147 INFO - Base dir: C:\Jenkins\workspace\Sprint3\Application\JmsUtils 
11:07:50.147 INFO - Working dir: C:\Jenkins\workspace\Sprint3\Application\.sonar\WSM_Application_JmsUtils 
11:07:50.147 INFO - Source dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\src\main\java 
11:07:50.147 INFO - Test dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\src\test\java 
11:07:50.147 INFO - Binary dirs: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\classes 
11:07:50.147 INFO - Source encoding: windows-1252, default locale: en_US 
11:07:50.147 INFO - Index files 
11:07:50.350 INFO - 4 files indexed 
11:07:50.428 INFO - Quality profile for java: WSM way with Findbugs - Server Code 
11:07:50.444 INFO - Sensor JavaSquidSensor... 
11:07:50.491 INFO - Java Main Files AST scan... 
11:07:50.506 INFO - 2 source files to be analyzed 
11:07:50.740 INFO - 2/2 source files analyzed 
11:07:50.756 INFO - Java Main Files AST scan done: 265 ms 
11:07:50.756 INFO - Java bytecode scan... 
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Connection' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/MessageProducer' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Message' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/ConnectionFactory' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Connection' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/Session' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'mil/navy/aif/domain/AuditRecord' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'javax/jms/JMSException' is not accessible through the ClassLoader. 
11:07:50.787 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.803 WARN - Class 'org/apache/log4j/Logger' is not accessible through the ClassLoader. 
11:07:50.803 INFO - Java bytecode scan done: 47 ms 
11:07:50.803 INFO - Java Test Files AST scan... 
11:07:50.803 INFO - 2 source files to be analyzed 
11:07:50.849 INFO - Java Test Files AST scan done: 46 ms 
11:07:50.849 INFO - 2/2 source files analyzed 
11:07:50.849 INFO - Package design analysis... 
11:07:50.865 INFO - Package design analysis done: 16 ms 
11:07:50.881 INFO - Sensor JavaSquidSensor done: 437 ms 
11:07:50.881 INFO - Sensor QProfileSensor... 
11:07:50.881 INFO - Sensor QProfileSensor done: 0 ms 
11:07:50.881 INFO - Sensor FindbugsSensor... 
11:07:50.896 INFO - Execute Findbugs 2.0.3... 
11:07:52.269 INFO - Findbugs output report: C:\Jenkins\workspace\Sprint3\Application\.sonar\WSM_Application_JmsUtils\findbugs-result.xml 
The following classes needed for analysis were missing: 
    javax.jms.Session 
    javax.jms.Connection 
    org.apache.log4j.Logger 
    javax.jms.ConnectionFactory 
    javax.jms.Message 
    javax.jms.MessageProducer 
    mil.navy.aif.domain.AuditRecord 
    javax.jms.JMSException 
    javax.jms.Topic 
    javax.jms.Destination 
11:07:54.609 INFO - Execute Findbugs 2.0.3 done: 3698 ms 
11:07:54.609 INFO - Sensor FindbugsSensor done: 3728 ms 
11:07:54.609 INFO - Sensor JaCoCoItSensor... 
11:07:54.609 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\jacoco-it.exec 
11:07:54.672 INFO - Sensor JaCoCoItSensor done: 63 ms 
11:07:54.672 INFO - Sensor JaCoCoOverallSensor... 
11:07:54.672 INFO - Sensor JaCoCoOverallSensor done: 0 ms 
11:07:54.672 INFO - Sensor CoberturaSensor... 
11:07:54.687 INFO - parsing C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\site\cobertura\coverage.xml 
11:07:54.765 INFO - Sensor CoberturaSensor done: 93 ms 
11:07:54.765 INFO - Sensor CpdSensor... 
11:07:54.765 INFO - SonarEngine is used for java 
11:07:54.765 INFO - Cross-project analysis disabled 
11:07:54.812 INFO - Sensor CpdSensor done: 47 ms 
11:07:54.812 INFO - Sensor InitialOpenIssuesSensor... 
11:07:54.890 INFO - Sensor InitialOpenIssuesSensor done: 78 ms 
11:07:54.890 INFO - Sensor ProfileEventsSensor... 
11:07:54.906 INFO - Sensor ProfileEventsSensor done: 16 ms 
11:07:54.906 INFO - Sensor ProjectLinksSensor... 
11:07:54.906 INFO - Sensor ProjectLinksSensor done: 0 ms 
11:07:54.906 INFO - Sensor VersionEventsSensor... 
11:07:54.921 INFO - Sensor VersionEventsSensor done: 15 ms 
11:07:54.921 INFO - Sensor FileHashSensor... 
11:07:54.921 INFO - Sensor FileHashSensor done: 0 ms 
11:07:54.921 INFO - Sensor SurefireSensor... 
11:07:54.921 INFO - parsing C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\surefire-reports 
11:07:54.937 INFO - Sensor SurefireSensor done: 16 ms 
11:07:54.937 INFO - Sensor JaCoCoSensor... 
11:07:54.937 INFO - Project coverage is set to 0% as no JaCoCo execution data has been dumped: C:\Jenkins\workspace\Sprint3\Application\JmsUtils\target\jacoco.exec 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION FAILURE 
INFO: ------------------------------------------------------------------------ 
Total time: 11.513s 
Final Memory: 21M/674M 
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: org.sonar.api.utils.SonarException: Can not add twice the same measure on [email protected][key=src/main/java/mil/navy/wsm/jmsutils/Auditor.java,deprecatedKey=mil.navy.wsm.jmsutils.Auditor,path=src/main/java/mil/navy/wsm/jmsutils/Auditor.java,dir=mil/navy/wsm/jmsutils,filename=Auditor.java,language=Java]: [email protected][id=<null>,metricKey=lines_to_cover,metric=Metric[id=38,formula=<null>,key=lines_to_cover,description=Lines to cover,type=INT,direction=1,domain=Tests,name=Lines to cover,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=false],value=28.0,data=<null>,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=<null>,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,requirement=<null>,personId=<null>,persistenceMode=FULL] 
    at org.sonar.batch.index.Bucket.addMeasure(Bucket.java:95) 
    at org.sonar.batch.index.DefaultIndex.addMeasure(DefaultIndex.java:209) 
    at org.sonar.batch.DefaultSensorContext.saveMeasure(DefaultSensorContext.java:168) 
    at org.sonar.plugins.jacoco.JaCoCoSensor$UnitTestsAnalyzer.saveMeasures(JaCoCoSensor.java:86) 
    at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:151) 
    at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107) 
    at org.sonar.plugins.jacoco.JaCoCoSensor.analyse(JaCoCoSensor.java:61) 
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79) 
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70) 
    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:131) 
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178) 
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) 
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) 
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:199) 
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:194) 
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:192) 
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:187) 
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) 
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) 
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:56) 
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44) 
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82) 
    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.BootstrapContainer.executeTask(BootstrapContainer.java:175) 
    at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:163) 
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) 
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) 
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92) 
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74) 
    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:606) 
    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 'Invoke Standalone Sonar Analysis' marked build as failure 
Finished: FAILURE 

Qui ci sono le proprietà del progetto che ho configurato a Jenkins per l'analisi SonarRunner:

sonar.projectKey=WSM:Application 
sonar.projectName=Application 
sonar.projectVersion=1.0.2.4-SNAPSHOT 
sonar.sources=src/main/java 
sonar.binaries=target/classes 
sonar.tests=src/test/java 
sonar.junit.reportsPath=target/surefire-reports 
sonar.java.coveragePlugin=cobertura 
sonar.cobertura.reportPath=target/site/cobertura/coverage.xml 
sonar.modules=JmsUtils,MsgGenerationUtils,WsmCopyAsNew,WsmGeomCreator,WsmGoldMsgParser,WsmJpa,WsmMsgGenerator 

Se rimuovo le e le sonar.cobertura.reportPath proprietà sonar.java.coveragePlugin, la generazione ha esito positivo, però io non avrà eventuali metriche di copertura.

Credo che il problema si verifichi perché c'è un conflitto con Cobertura e JaCoCo che cercano di misurare entrambi gli stessi file. È possibile vedere nella traccia stack che il sensore JaCoCo è coinvolto nell'errore. Non voglio affatto usare JaCoCo. Versione

Jenkins: versione 1.560
Jenkins Sonar Plugin: versione 2.1
Sonar: 4.3
Sonar Cobertura Plugin versione: La versione 1.6.1
Sonar Java Plugin: 2.2

risposta

1

Si prega di utilizzare la versione plug-in Java 2.2.1 che è stato rilasciato per risolvere questo problema.

Nella versione 2.2 se non è presente alcun rapporto JaCoCo imposta la copertura su 0 che provoca il problema riscontrato. Mentre in 2.2.1 se non è presente alcun rapporto, la copertura non è impostata.

3

Una soluzione alternativa alla versione 2.2. ist per impostare

sonar.jacoco.reportMissing.force.zero=False 

in sonar-project.properties.

0

Nel mio caso l'errore è stato generato perché ho provato a caricare contemporaneamente Jacoco e Cobertura. Devi scegliere uno dei plugin di copertura.