Sonar-Jenkins 管道 中 未 显示 JUnit 测试

ig9co6j1  于 2022-11-21  发布在  Jenkins
关注(0)|答案(2)|浏览(182)

这是我的sonar.properties档案

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

我已经手动推送了测试报告,下面是Jenkins文件中的单元测试命令

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'
rpppsulh

rpppsulh1#

您需要使用jacoco maven插件(https://www.jacoco.org/)生成覆盖率报告。

unitTestCommand          = 'cd library/core && mvn org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report && mvn surefire-report:report'
dldeef67

dldeef672#

**问题已解决:**路径中存在问题,sonar.junit.reportsPath应指向目录而不是特定文件:

sonar.junit.reportsPath=library/core/target/surefire-reports/

相关问题