Monorepo SonarQube scans aren't picking up the Jacoco and JUnit XML reports

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) : * Enterprise Edition Version 9.2.4 (build 50792)
  • what are you trying to achieve : publish reports to PR and sonarqube
  • what have you tried so far to achieve this : configured plugin and sonar-properties file

My services are not having their Jacoco and JUnit XML reports picked up even though the paths are correct in sonar-project.properties

Project scanner properties:
sonar.organization=og
sonar.projectKey=wf-query-service
sonar.projectName=wf-query-service
sonar.sourceEncoding=UTF-8
sonar.sources=src/main,src/models,src/sdk
sonar.tests=src/test,src/testkit
sonar.java.source=11
sonar.junit.xmlReportPaths=build/test-results/test/*.xml
sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/*.xml
sonar.java.binaries=build/classes/java/main,build/classes/java/models,build/classes/java/sdk
sonar.java.libraries=build/libs
sonar.java.coveragePlugin=jacoco
sonar.verbose=true

I have validated that the paths to both the Jacoco and JUnit XML reports are correct.

I am running all the scan in jenkins agent pod how do I check the correct path and fix this issue.

CI file

  container('jdk') {
    if (params.SONARQUBE_ENABLED) {
      stage('Run SonarQube') {
        withSonarQubeEnv() {
          def scannerHome = tool 'SonarScanner';
          def sonarParams = ""
          if (env.BRANCH_NAME != 'master') {
            sonarParams = "-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} \
              -Dsonar.pullrequest.key=${env.CHANGE_ID} \
              -Dsonar.pullrequest.base=${env.CHANGE_TARGET}"
          } else {
            sonarParams = "-Dsonar.branch.name=${env.BRANCH_NAME}"
          }

          sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectBaseDir=${params.GRADLE_SETTINGS_PATH}/${params.SERVICE_NAME}/ ${sonarParams}"
        }
      }
      stage("SonarQube Quality Gate check") {
        //Force to fail step after specific time
        timeout(time: 3, unit: 'MINUTES') {
          // Reuse taskId previously collected by withSonarQubeEnv
          def qg = waitForQualityGate()
          if (qg.status != 'OK') {
            error "Pipeline aborted due to quality gate failure: ${qg.status}"
          }
        }
      }
    }
  }

Hi,

Can you provide the full analysis log, please?

 
Ann

Okay Yeah here it is
log.txt (171.2 KB)

Hi,

The logs indicate a report is being read:

[2022-07-26T16:59:30.442Z] 16:59:24.186 INFO: Sensor JaCoCo XML Report Importer [jacoco]
[2022-07-26T16:59:30.457Z] 16:59:24.188 INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
[2022-07-26T16:59:30.471Z] 16:59:24.188 INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
[2022-07-26T16:59:30.486Z] 16:59:24.188 DEBUG: Reading report '/home/jenkins/agent/workspace/development-wf-export-service/services/budget/wf-export-service/build/reports/jacoco/test/jacocoTestReport.xml'
[2022-07-26T16:59:30.503Z] 16:59:24.255 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=69ms

Is this the right report file?
And does it include coverage for any of the files changed in the PR?
For that matter, does the PR change actual code? Or maybe just configuration files?

 
Ann