Sonar / JaCoCo4sbt / Jenkins

浪子不回头ぞ 提交于 2019-12-09 07:18:38

问题


I would like to know whats the easiest way to plug JaCoCo4sbt's data into Sonar, In Jenkins I have installed Sonar & JaCoCo's plugins. I have also installed JaCoCo's plugin in Sonar.

My sonar-project.properties file contains :

sonar.jacoco.reportPath=target/jacoco/jacoco.exec

And Jenkins's job execute these commands :

sbt jacoco:cover
/opt/sonar-runner/bin/sonar-runner
SBT_OPTS="-Dsbt.log.noformat=true"
sbt clean update compile test doc

For now I don't get any code coverage data into Sonar


回答1:


Do you want to report code coverage on Scala code using the Scala plugin for Sonar (http://docs.codehaus.org/display/SONAR/Scala+Plugin)? Unfortunately it does not yet provide a sensor for code coverage. It's on the roadmap for future versions.

At least jacoco4sbt successfully generates the file jacoco.exec but it is just not picket up by the Scala plugin.




回答2:


You'll need the following properties:

sonar.dynamicAnalysis=reuseReports
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reportPath=${build.dir}/jacoco.exec

I don't use sbt, but the following is an ANT example:

  • Add ant plugins dynamically at buildtime?

Check the properties file at the end for all the Sonar related stuff.



来源:https://stackoverflow.com/questions/17083605/sonar-jacoco4sbt-jenkins

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