This is my sonar.properties file
sonar.host.url=https://sonar.cloud.health.ge.com/
sonar.projectKey=ils
sonar.projectName=ILS
sonar.projectVersion=1.0.0
sonar.sources=library/core
sonar.java.binaries=library/core/target/classes
sonar.exclusions=library/core/target/**/*, library/core/src/test/**/*
sonar.tests=library/core/src/test/
sonar.java.test.libraries=library/core/target/test-classes/
> sonar.junit.reportsPath=library/core/target/surefire-reports/CalculatorTest.xml
// test cases are generated fine but sonarqube is not taking the junit reports in the pipeline
sonar.coverage.jacoco.xmlReportPaths=library/core/target/site/jacoco/jacoco.xml
I have pushed the testreports manually and Below is the unit-test command in Jenkins File
unitTestCommand = 'cd library/core && mvn test && mvn surefire-report:report'
unitTestReportDir = 'library/core/target/site'
arch = 'hc-eu-west-aws-artifactory.cloud.health.ge.com/docker-eis-all/build-tools-eis-repo:1.0.0'
CodePudding user response:
You need to use jacoco maven plugin (https://www.jacoco.org/) for generate report with coverage.
unitTestCommand = 'cd library/core && mvn org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report && mvn surefire-report:report'
CodePudding user response:
ISSUE RESOLVED: There was an issue in the path, sonar.junit.reportsPath should point to a directory rather than a specific file:
sonar.junit.reportsPath=library/core/target/surefire-reports/