Code coverage is 0 for gradle project- which built via cloudbess jenkins

Must-share information (formatted with Markdown):

  1. SonarQube : 9.5.0.56709,
  2. Scanner version from build.gradle file : id “org.sonarqube” version “3.1.1”
  3. Things about jacoco we have in build.gradle file :
    i. Enabled jacoco plugin
    ii. jacoco toolVersion = “0.8.7”
    iii. jacocoTestReport also enabled

Attaching screenshot :

  • I would suggest using the latest version of the SonarScanner for Gradle, 3.4
  • Have you followed the instructions in this guide?

Hi Colin thanks for ur reply

i changed version of the SonarScanner for Gradle to 3.4.0.2513

Though jenkins job is success, at the sonar side still code coverage is 0. But strange is qualitygate has PASSED though code coverage is 0.

Attaching screenshots :

Need help in this

Need help in this

Hey there.

Please do not bump threads.

I would again ask this:

And suggest you share your build.gradle file.

i gone through that page.

content of sonar and jacoco in my build.gradle are as below :

  1. plugins { id “org.sonarqube” version “3.4.0.2513” }
  2. test {
    finalizedBy jacocoTestReport
    }
  3. jacocoTestReport {
    dependsOn test // tests are required to run before generating the report
    }

jacoco {
toolVersion = “0.8.7”
}

jacocoTestReport {

reports {
    xml.enabled true
    html.enabled true
    csv.enabled false
}

}

project.tasks[“sonarqube”].dependsOn “jacocoTestReport”

  1. sonarqube {
    properties {
    property ‘sonar.projectKey’, ‘KEY-NAME’
    property ‘sonar.projectName’, 'NAME OF THE PROJECT
    property “sonar.coverage.exclusions”, “/model/,/config/,/test/,/generated/,/exception/
    property “sonar.coverage.jacoco.xmlReportPaths”, “${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml”
    }
    }
    build.finalizedBy([“jacocoTestReport”])

i need help on this colin

Hey there.

  • Have you made sure that an XML coverage report has actually been produced? SonarQube only reads coverage reports, it’s not involved in producing them, and you’ll need to make sure that report exists (outside the context of SonarQube) before anything else.
  • If the report does exist, I would suggest referring to this guide to find out what the scanner logs are saying: