From b8a96b1f21131a5ad3448c9e34f1fd751a8ca16d Mon Sep 17 00:00:00 2001 From: Rafael Dominguez <5624449+raphaelDL@users.noreply.github.com> Date: Fri, 23 Nov 2018 13:28:46 -0600 Subject: [PATCH] Enable Code Coverage Reports in Sonar This commit ensures that jacocoTestReport task is called when running the Sonar stage. Additionally, a variable is passed instructing Sonar where to find the test result data. Fixes: gh-6092 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a59a650d43..c96e85f148 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ try { checkout scm withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) { try { - sh "./gradlew clean sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon --stacktrace" + sh "./gradlew clean jacocoTestReport sonarqube -Dsonar.jacoco.reportPaths='**/build/jacoco/*.exec' -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon --stacktrace" } catch(Exception e) { currentBuild.result = 'FAILED: sonar' throw e