Sonar / JaCoCo4sbt / Jenkins

2019-03-22 07:09发布

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

2条回答
\"骚年 ilove
2楼-- · 2019-03-22 07:29

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:

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

查看更多
老娘就宠你
3楼-- · 2019-03-22 07:32

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.

查看更多
登录 后发表回答