Coverage report works in Jenkins using Jacoco but I cannot get coverage report in SonarQube

天涯浪子 提交于 2020-01-05 08:34:47

问题


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:

It shows coverage report and other information. But I cannot get coverage percentage in sonarQube therefore the quality gate in Sonarqube cannot be passed.

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.


回答1:


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




回答2:


sonar reads the jacocoexec file created by the plugin execution , you can under the target fodler of your project if the file is getting created, if the path of the file is different you need to provide it in the sonar properties file



来源:https://stackoverflow.com/questions/51798478/coverage-report-works-in-jenkins-using-jacoco-but-i-cannot-get-coverage-report-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!