覆盖率报告使用Jacoco在Jenkins中工作,但我无法在SonarQube中获得覆盖率报告 [英] Coverage report works in Jenkins using Jacoco but I cannot get coverage report in SonarQube
问题描述
我正在使用Jenkins + Jacoco + Sonarqube来测试我的代码. 在Jenkins中,我的mvn命令是:
I'm using Jenkins+Jacoco+Sonarqube to test my code. In Jenkins, my mvn command is:
clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.skip=false -Dmaven.test.failure.ignore=true sonar:sonar
在构建后添加动作记录雅各布覆盖率报告".
And I add action 'record jacoco coverage report' after build.
但是结果是,詹金斯的工作原理如下:
But the result is, jenkins works as below:
它显示覆盖率报告和其他信息.但是我无法在sonarQube中获得覆盖率,因此无法通过Sonarqube中的质量门.
It shows coverage report and other information. But I cannot get coverage percentage in sonarQube therefore the quality gate in Sonarqube cannot be passed.
我想声纳找不到覆盖率报告,因为它不在SonarQube的代码"选项卡中.
I guess that sonar cannot find the coverage report because it's not exist in the 'code' tab in SonarQube.
请帮助我,我急需解决方案.
Please help me, I need the solution desperately.
推荐答案
为了在SonarQube中显示覆盖范围,您应该配置sonarqube.properties文件.在声纳属性中,有一个名为sonar.jacoco.reportPaths
的参数.您应该通过提供jacoco.exec
文件的路径来添加此参数.例如:
In order to display your coverage in SonarQube, you should configure your sonarqube.properties file. In sonar properties, there is a parameter called sonar.jacoco.reportPaths
. You should add this parameter by giving the path of your jacoco.exec
file. For example:
sonar.jacoco.reportPaths=yourpath/jacoco.exec
这篇关于覆盖率报告使用Jacoco在Jenkins中工作,但我无法在SonarQube中获得覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!