SonarCloud Integration with gradle project(Code coverage is Zero)

Hi,
I have configured Sonarcloud analysis for my grade project in Jenkins, Below is my configuration in build.gradle file to generate code coverage for my project.

plugins {
	id 'org.springframework.boot' version '2.7.0'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
	id 'jacoco'
	id "org.sonarqube" version "4.2.1.3168"
}

sonar {
  properties {
    property "sonar.projectKey", "XXXXXXX"
    property "sonar.organization", "XXX"
    property "sonar.host.url", "https://sonarcloud.io"
	property "sonar.login", "XXXX"
	property "sonar.branch.name", "development"
	property "sonar.sources", "src"
  }
}

group = 'com.XXX'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
	mavenCentral()
}

ext {
	set('springCloudVersion', '2021.0.3')
}

jacoco {
	toolVersion = "0.8.10"
}
test {
	finalizedBy jacocoTestReport
}
jacocoTestReport {
	dependsOn test
}

We are using gradle version 6.9.1, After configuring the command gradlew sonarqube in my Jenkins Build step,Other than code coverage all other parameters have some values but code coverage is showing as Zero.

Please guide me to resolve this issue if any configuration needs to change in my build.gradle file let me know.

Appreciate your answers to resolve the issue.

Hi,

Analysis doesn’t automatically pick up your coverage reports. You need to pass them in.

 
HTH,
Ann