简体   繁体   English

詹金斯+声纳

[英]Jenkins + Sonar

I have a project Pensky with two build Jobs on my Jenkins Server. 我的Jenkins服务器上有一个包含两个构建Jobs的Pensky项目。 The First Build job does maven build and collects JaCoCo Code coverage report on Post Build Action. First Build作业会进行maven生成,并收集有关Post Build Action的JaCoCo代码覆盖率报告。

My Second Build Job runs Sonar Analysis on my project. 我的第二个构建作业在我的项目上运行声纳分析。 I would like to reuse/feed the JaCoCo code coverage report into my Sonar. 我想将JaCoCo代码覆盖率报告重新使用/输入到我的Sonar中。 But, unable to do so. 但是,无法这样做。 I see the below message in my build job console 我在构建作业控制台中看到以下消息

"Project coverage is set to 0% as build output directory does not exist:" “由于构建输出目录不存在,因此项目覆盖率设置为0%:”

The sonar job is looking for 'classes' folder in the .sonar directory (in the jenkins job directory). 声纳作业正在.sonar目录(在jenkins作业目录中)中查找“ classes”文件夹。

Can anyone guide me how to feed the report into Sonar. 谁能指导我如何将报告提交至Sonar。 Thank you 谢谢

This is my sonar.properties 这是我的sonar.properties

    sonar.projectKey=Pensky
    sonar.projectName=Pensky
    sonar.projectVersion=1.1
    sonar.projectDescription= GE Pensky
    sonar.sources=src/main/java
    sonar.tests=src/test/java
    sonar.language=java
    sonar.my.property=value
    sonar.forceAnalysis=true
sonar.jacoco.reportPath=target/jacoco.exec

您尚未将“ sonar.binaries”属性设置为指向构建目录(如果使用Maven进行编译,则为“ target / classes”)。

First of all, you should to copy the folder target of the first job in order to save time. 首先,您应该复制第一个作业的文件夹目标以节省时间。 If you do that, you have in the workspace of the job, all the binaries and the jacoco.exec file. 如果执行此操作,则作业的工作区中将包含所有二进制文件和jacoco.exec文件。

Then, you have to set the folder of the tests result. 然后,您必须设置测试结果的文件夹。

sonar.junit.reportsPath=target/surefire-reports(or other) sonar.jacoco.ReportPath=target/jacoco.exec sonar.junit.reportsPath = target / surefire报告(或其他)sonar.jacoco.ReportPath = target / jacoco.exec

And finally, you have to set the binaries folder. 最后,您必须设置binaries文件夹。

sonar.binaries=target/classes sonar.binaries =目标/类别

Hope I have been helpful. 希望我有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM