问题
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.
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
All of the results Unit Tests Coverage 0.0% Line Coverage 0.0%
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?
Thanks.
- Ben
回答1:
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.
Solution was to fix the paths:
replace="s|/home/bamboo/project/|`pwd`/|g"
sed -i -- $replace report/*.xml
来源:https://stackoverflow.com/questions/31840022/jenkins-php-unit-test-and-code-coverage-unable-to-import-in-sonarqube