3

我有一个 JavaScript 项目,我正在使用 Sonar 进行分析。一切正常,除了代码覆盖率分析。

我正在使用 Karma 创建线路覆盖lcov.info文件。

当我从我的 cmd / cywin 进行分析时,使用:

mvn sonar:sonar -Pci-sonar-js

一切正常,Sonar 显示代码覆盖率,当我在我的 Jenkins Job 中做同样的事情时。代码覆盖率显示为 0%!

Sonar解析lcov.info文件,除了解析文件的时长(cmd~60ms,jenkins~30ms)外,解析的输出并没有什么区别。

pom.xml 的声纳部分

<profile>
    <id>ci-sonar-js</id>

    <properties>
        <sonar.branch>JavaScript</sonar.branch>
        <sonar.language>js</sonar.language>
        <sonar.exclusions>src/test/webapp/lib/**,**/datepick.min.js,**/fileupload.js,**/fileupload.min.js,**/moment.js,**/moment.min.js,**/script.min.js,**/syntaxhighlighter.js,**/syntaxhighlighter.min.js</sonar.exclusions>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>

        <sonar.javascript.jstest.reportsPath>target/surefire-reports/</sonar.javascript.jstest.reportsPath>
        <sonar.javascript.lcov.reportPath>target/lcov.info</sonar.javascript.lcov.reportPath>

        <ci.build.sourceDirectory>${basedir}/target/classes/META-INF/public/js/min/</ci.build.sourceDirectory>
        <ci.build.testSourceDirectory>${basedir}/src/test/webapp/</ci.build.testSourceDirectory>
    </properties>

    <build>
        ...
    </build>
</profile>

詹金斯日志:

[Sonar JavaScript] $ C:\tools\apache-maven-3.0.5\bin\mvn.bat -f "c:\workspace\Sonar JavaScript\pom.xml" -e -B sonar:sonar -Pci-sonar-js -Dsonar.jdbc.driver=oracle.jdbc.OracleDriver -Dsonar.jdbc.url=jdbc:oracle:thin:@<my_shortened_db_connection> ******** ******** -Dsonar.host.url=http://<my_shortened_hostname>:9000 -Dsonar.branch=JavaScript -Dsonar.language=js
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 1.0.0.05-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:2.1:sonar (default-cli) @ myProject ---
[INFO] SonarQube version: 3.6.2
[INFO] [16:51:59.960] Load batch settings
[INFO] [16:52:00.007] User cache: C:\Dokumente und Einstellungen\<my_shortened_user>\.sonar\cache
[INFO] [16:52:00.069] Install plugins
[INFO] [16:52:00.726] Install JDBC driver
[INFO] [16:52:00.741] Create JDBC datasource for jdbc:oracle:thin:@<my_shortened_db_connection>
[INFO] [16:52:02.163] Initializing Hibernate
[INFO] [16:52:08.898] Load project settings
[INFO] [16:52:08.913] Apply project exclusions
[INFO] [16:52:09.023] -------------  Scan myProject JavaScript
[INFO] [16:52:09.023] Load module settings
[INFO] [16:52:09.288] Quality profile : [name=Sonar way,language=js]
[INFO] [16:52:09.304] Excluded sources: 
[INFO] [16:52:09.304]   src/test/webapp/lib/**
[INFO] [16:52:09.304]   **/datepick.min.js
[INFO] [16:52:09.304]   **/fileupload.js
[INFO] [16:52:09.304]   **/fileupload.min.js
[INFO] [16:52:09.304]   **/moment.js
[INFO] [16:52:09.304]   **/moment.min.js
[INFO] [16:52:09.304]   **/script.min.js
[INFO] [16:52:09.304]   **/syntaxhighlighter.js
[INFO] [16:52:09.304]   **/syntaxhighlighter.min.js
[INFO] [16:52:09.304] Excluded tests: 
[INFO] [16:52:09.304]   **/package-info.java
[INFO] [16:52:09.335] Configure Maven plugins
[INFO] [16:52:09.367] Compare to previous analysis (2013-09-23)
[INFO] [16:52:09.382] Compare over 5 days (2013-09-18, analysis of 2013-09-23 14:22:37.579)
[INFO] [16:52:09.382] Compare over 30 days (2013-08-24, analysis of 2013-09-23 14:22:37.579)
[INFO] [16:52:09.679] Base dir: c:\workspace\Sonar JavaScript
[INFO] [16:52:09.679] Working dir: c:\workspace\Sonar JavaScript\target\sonar
[INFO] [16:52:09.679] Source dirs: c:\workspace\Sonar JavaScript\target\classes\META-INF\public\js\min
[INFO] [16:52:09.679] Test dirs: c:\workspace\Sonar JavaScript\src\test\webapp
[INFO] [16:52:09.679] Binary dirs: c:\workspace\Sonar JavaScript\target\classes
[INFO] [16:52:09.679] Source encoding: UTF-8, default locale: de_DE
[INFO] [16:52:09.710] Sensor JavaScriptSourceImporter...
[INFO] [16:52:09.804] Sensor JavaScriptSourceImporter done: 94 ms
[INFO] [16:52:09.804] Sensor JavaScriptSquidSensor...
[INFO] [16:52:11.101] Sensor JavaScriptSquidSensor done: 1297 ms
[INFO] [16:52:11.101] Sensor LCOVSensor...
[INFO] [16:52:11.101] Analysing C:\workspace\Sonar JavaScript\target\lcov.info
[INFO] [16:52:11.132] Sensor LCOVSensor done: 31 ms
[INFO] [16:52:11.132] Sensor JsTestSensor...
[INFO] [16:52:14.382] Sensor JsTestSensor done: 3250 ms
[INFO] [16:52:14.382] Sensor CpdSensor...
[INFO] [16:52:14.382] SonarBridgeEngine is used
[INFO] [16:52:14.382] Cross-project analysis disabled
[INFO] [16:52:14.601] Sensor CpdSensor done: 219 ms
[INFO] [16:52:14.601] Sensor InitialOpenIssuesSensor...
[INFO] [16:52:14.601] Sensor InitialOpenIssuesSensor done: 0 ms
[INFO] [16:52:14.601] Sensor ProfileSensor...
[INFO] [16:52:14.617] Sensor ProfileSensor done: 16 ms
[INFO] [16:52:14.617] Sensor ProfileEventsSensor...
[INFO] [16:52:14.632] Sensor ProfileEventsSensor done: 15 ms
[INFO] [16:52:14.632] Sensor ProjectLinksSensor...
[INFO] [16:52:14.648] Sensor ProjectLinksSensor done: 16 ms
[INFO] [16:52:14.648] Sensor VersionEventsSensor...
[INFO] [16:52:14.664] Sensor VersionEventsSensor done: 16 ms
[INFO] [16:52:14.664] Sensor Maven dependencies...
[INFO] [16:52:15.570] Sensor Maven dependencies done: 906 ms
[INFO] [16:52:15.882] Execute decorators...
[INFO] [16:52:19.476] Store results in database
[INFO] [16:52:19.570] ANALYSIS SUCCESSFUL, you can browse http://<my_shortened_hostname>:9000/dashboard/index/com.mycompany:myProject:JavaScript
[INFO] [16:52:19.570] Executing post-job class org.sonar.plugins.doxygen.DoxygenPostJob
[ERROR] [16:52:19.570] The global property 'sonar.doxygen.deploymentPath' is not set. Set it in SONAR and run another analysis.
[INFO] [16:52:19.570] Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
[INFO] [16:52:19.570] Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
[INFO] [16:52:19.648] Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
[INFO] [16:52:19.664] -> Keep one snapshot per day between 2013-08-26 and 2013-09-22
[INFO] [16:52:19.664] -> Keep one snapshot per week between 2012-09-24 and 2013-08-26
[INFO] [16:52:19.664] -> Keep one snapshot per month between 2008-09-29 and 2012-09-24
[INFO] [16:52:19.664] -> Delete data prior to: 2008-09-29
[INFO] [16:52:19.664] -> Clean myProject JavaScript [id=14180]
[INFO] [16:52:19.679] <- Clean snapshot 118948
[INFO] [16:52:19.976] Executing post-job class org.sonar.plugins.buildbreaker.AlertBreaker
[INFO] [16:52:19.976] Executing post-job class org.sonar.plugins.buildbreaker.ForbiddenConfigurationBreaker
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.251s
[INFO] Finished at: Mon Sep 23 16:52:20 CEST 2013
[INFO] Final Memory: 22M/172M
[INFO] ------------------------------------------------------------------------
Sonar analysis completed: SUCCESS
Zeichne Testergebnisse auf.
Finished: SUCCESS
4

0 回答 0