【发布时间】:2017-12-11 02:36:05
【问题描述】:
我配置了一个 Jenkins 构建来运行 SonarQube,我看到了除代码覆盖率之外的所有结果。我可以在 surefire-reports 目录中看到 xml 和 txt 文件,我还看到了 jacoco.exec,所以我对我缺少的东西感到困惑,我怀疑这将是一些超级基本的东西。
SonarQube 版本:6.3.1 詹金斯:2.46.2
这是我在 Jenkins 中的 SonarQube 配置:
# metadata
sonar.projectName=${JOB_NAME}
sonar.projectVersion = 0.1
#path to source
sonar.projectBasedDir=${WORKSPACE}
sonar.sources=src/... (removed specific path)
sonar.binaries=target/classes
#report location
sonar.junit.reportPaths=${project.build.directory}/target/surefire-reports sonar.jacoco.reportPaths=${project.build.directory}/target/surefire-reports/jacoco.exec
#testing parms
sonar.verbose=true
sonar.tests=src/test/java
sonar.language=java
这是来自我的 POM 的插件数据:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>${argLine}</argLine>
<runOrder>random</runOrder>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>${basedir}/target/surefire-reports/jacoco.exec</destFile>
<dataFile>${basedir}/target/surefire-reports/jacoco.exec</dataFile>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.20</version>
</dependency>
【问题讨论】:
-
能否包含用于扫描的 maven 命令?
-
@Tim 我正在使用 mavem 目标 - 清理测试包
-
我把你的 pom 和我的一些比较。我使用 maven-surefire-plugin,而不是您正在使用的 apache(如果这有什么不同的话)。但要进行扫描,“mvn -U clean org.jacoco-maven-plugin:prepare-agent install org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=http:/ /"
-
@蒂姆。感谢您的输入。 maven 插件 (org.jacoco:jacoco-maven-plugin:prepare-agent) 有一个小的语法差异,一旦我解决了这个问题,我们就开始比赛了。
-
@ApolloRaptor 如果您要去参加比赛,能否提供您的解决方案作为答案?
标签: maven jenkins sonarqube-scan