我有Jenkins v1.651.1和SonarQube Runner 2.4和SonarQube Server 4.5.2。
Jenkins作业运行mvn clean test
以生成.exec
报告。我的分析属性(Jenkins构建的一部分)看起来像这样:
sonar.sources=myproj
sonar.tests=myproj/runtime/src/test
sonar.language=java
sonar.java.test.binaries=myproj/runtime/target/test-classes
sonar.java.test.libraries=myproj/runtime/target/admin/WEB-INF/lib/*.jar
sonar.java.binaries=myproj/runtime/target/classes
sonar.java.libraries=myproj/runtime/target/admin/WEB-INF/lib/*.jar
sonar.java.source=1.8
sonar.java.coveragePlugin=jacoco
sonar.sourceEncoding=UTF-8
sonar.jacoco.reportPath=myproj/target/jacoco.exec
sonar.junit.reportsPath=myproj/runtime/target/surefire-reports
作业成功完成,但我的声纳仪表板看起来像this,作业无法找到类文件:
02:35:52.170 INFO - Sensor JaCoCoItSensor...
02:35:52.171 INFO - No JaCoCo analysis of project coverage can be done since there is no class files.
02:35:52.172 INFO - Sensor JaCoCoItSensor done: 2 ms
02:35:52.172 INFO - Sensor JaCoCoOverallSensor...
02:35:52.172 INFO - Sensor JaCoCoOverallSensor done: 0 ms
02:35:52.172 INFO - Sensor JaCoCoSensor...
02:35:52.172 INFO - No JaCoCo analysis of project coverage can be done since there is no class files.
02:35:52.172 INFO - Sensor JaCoCoSensor done: 0 ms
02:35:52.172 INFO - Sensor CPD Sensor (wrapped)...
02:35:52.172 INFO - JavaCpdEngine is used for java
在标记为重复之前,请注意我已尝试设置sonar.java.binaries
。
我还验证了.exec
文件在那里,并且在本地打开时具有我期望的覆盖值。请帮忙!感谢。
答案 0 :(得分:0)
您是否尝试将此添加到pom.xml
?
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
...