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}"
}
}
}
}
}