Sonarqube code coverage for php project is 0

My configuaration as follows-
SonarQube plugins:

  • SonarPython (python)
  • SonarCSS (cssfamily)
  • GitHub Authentication for SonarQube (authgithub)
  • JaCoCo (jacoco)
  • SonarGo (go)
  • SonarKotlin (kotlin)
  • Svn (scmsvn)
  • SonarJS (javascript)
  • SonarRuby (ruby)
  • SonarScala (sonarscala)
  • SonarC# (csharp)
  • SonarJava (java)
  • LDAP (ldap)
  • SonarHTML (web)
  • Git (scmgit)
  • SonarFlex (flex)
  • SonarXML (xml)
  • SAML 2.0 Authentication for SonarQube (authsaml)
  • SonarPHP (php)
  • SonarTS (typescript)
  • SonarVB (vbnet)
    Global server settings:
  • sonar.core.startTime=******
  • sonar.php.coverage.reportPaths=src/app/coverage.xml
    Project server settings:
  • sonar.php.coverage.reportPaths=coverage.xml
    Project scanner properties:
  • sonar.login=******
  • sonar.projectBaseDir=/home/jenkins/workspace/PHP-Pipeline/src/app
  • sonar.projectKey=om-common
  • sonar.scanner.appVersion=
  • sonar.sourceEncoding=US-ASCII
  • sonar.sources=.

We have placed coverage.xml under src/app/ in our scm.

however i’m getting code coverage 0 for PHP project

Hey there.

You are using a very old version of SonarQube. Make sure you upgrade to at least v8.9 LTS (or go as far as v9.7) as let us know if you’re still facing an issue.

Hi @Colin
Thank you for update.
we are using community edition screenshot attached. I can’t upgrade sonarqube now.

is this version compatible for php code coverage?
our configuration is Gitlab->jenkins->sonarqube
Please help me with this

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9 → 8.9.10 → 9.7.1 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your issue persists after upgrade, please come back to us.

Hi @Colin
Can you please confirm, Is “sonar.php.tests.reportPath” mandatory attribute in order to generate the code coverage?
If yes, how we can generate that report?
Do we need to write this report(test cases) manually?

Hey there.

We can’t provide support in this community for an EOL version of SonarQube, which is why I’m pushing you to upgrade first of all. :slight_smile:

And, you can find more details about PHP Test Coverage in the documentation, including an example of how to generate the report and pass it to sonar.php.coverage.reportPaths