We are trying to get code coverage push on PR analysis. We have the following Jenkins configuration that is integrated with SonarCloud:
sh "${scannerHome}/bin/sonar-scanner " +
"-Dsonar.projectKey=repo-key " +
"-Dsonar.organization=my-org " +
"-Dsonar.sources=app_dir " +
"-Dsonar.python.coverage.reportPaths=generated-reports/*cov*.xml " +
"-Dsonar.python.xunit.reportPath=generated-reports/junit.xml " +
"-Dsonar.exclusions=cambyses/global_config.py " +
"-Dsonar.coverage.exclusions=tests/**/*,generated-reports/* " +
"-Dsonar.pullrequest.branch=${env.BRANCH_NAME} " +
"-Dsonar.pullrequest.key=${CHANGE_ID} " +
"-Dsonar.pullrequest.base=master " +
"-Dsonar.pullrequest.provider=github " +
"-Dsonar.pullrequest.github.repository=SLUG/repo "
Looking at the cov.xml file it looks setup correctly:
<source>
/home/jenkins/workspace/<workspace_name>/app_dir
</source>
<source>...</source>
</sources>
<sources>...</sources>
We see it trying to parse the right files in the console log:
INFO: Sensor Python Squid Sensor [python]
INFO: 3/3 source files have been analyzed
INFO: Sensor Python Squid Sensor [python] (done) | time=2936ms
INFO: Sensor Cobertura Sensor for Python coverage [python]
WARN: Property 'sonar.python.coverage.reportPath' is deprecated. Please use 'sonar.python.coverage.reportPaths' instead.
WARN: No report was found for sonar.python.coverage.reportPath using pattern cov.xml
INFO: Python test coverage
INFO: Parsing report '/home/jenkins/workspace/<workspace_name>/generated-reports/cov.xml'
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=86ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Processing report '/home/jenkins/workspace/<workspace_name>/generated-reports/junit.xml'
INFO: Sensor PythonXUnitSensor [python] (done) | time=34ms
However, we are not seeing code coverage metrics on the PR branch. We have inspected the cov.xml artifact and it definitely exist with the coverage results we would expect.
Thanks in advance.