Jenkins PHP单元测试和代码覆盖率无法在SonarQube中导入 [英] Jenkins PHP Unit Test and Code Coverage unable to import in SonarQube

查看:137
本文介绍了Jenkins PHP单元测试和代码覆盖率无法在SonarQube中导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力将Jenkins的单元测试结果和代码覆盖范围导入SonarQube.至此,我已经验证了正在生成的结果,这些结果显示在Jenkins的项目页面中.

I have been struggling with importing unit test results and code coverage from Jenkins into SonarQube. At this point, I have verified the results are being generated as they are displayed in the project's page in Jenkins.

sonar.properties文件如下所示. php结果是使用phpunit创建的,代码覆盖率是使用phpunit和三叶草创建的.为了排除故障,我同时包含了sonar.php.coverage.reportPath和sonar.clover.reportPath.

The sonar.properties file is shown below. The php results were created with phpunit and the code coverage was created with phpunit and clover. As an effort in troubleshooting, I included both sonar.php.coverage.reportPath and sonar.clover.reportPath.

sonar.projectKey=projectKey
sonar.projectName=projectKey
sonar.projectVersion=1.0
sonar.language=php
sonar.sourceEncoding=UTF-8

sonar.php.tests.reportPath=report/phpunitresults.xml
sonar.php.coverage.reportPath=report/clover_code_coverage.xml
sonar.clover.reportPath=report/clover_code_coverage.xml 

sonar.sources=./src/
sonar.exclusions=./src/tests/**
sonar.tests=./src/tests/
sonar.coverage.exclusions=./src/tests/**/*.php

所有结果 单元测试范围 0.0% 线路覆盖 0.0%

All of the results Unit Tests Coverage 0.0% Line Coverage 0.0%

Jenkins版本在识别为什么不导入结果的问题时不会产生任何错误或有用的信息.

The Jenkins builds do not produce any errors or helpful information in identifying a problem as to why the results are not being imported.

任何人都可以帮助解决问题吗?

Can anyone help in troubleshooting the issue?

谢谢.

推荐答案

我的问题是,覆盖率报告是在与运行sonar-scanner的服务器不同的服务器上生成的,而clover.xml中的绝对路径也不同.

My problem was that coverage reports were generated on server different from where sonar-scanner was run, and the absolute paths in clover.xml differed.

解决方案是修复路径:

replace="s|/home/bamboo/project/|`pwd`/|g"
sed -i -- $replace report/*.xml

这篇关于Jenkins PHP单元测试和代码覆盖率无法在SonarQube中导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆