fix: replace jacocoAdapter with publishHTML for Jenkins compatibility

This commit is contained in:
wangtianqi 2025-06-23 21:58:12 +08:00
parent f2a1a146b7
commit 194442170e

16
Jenkinsfile vendored
View File

@ -87,11 +87,19 @@ pipeline {
if (fileExists('target/surefire-reports/*.xml')) {
publishTestResults testResultsPattern: 'target/surefire-reports/*.xml'
}
// 发布代码覆盖率报告 - 使用新语法
// 发布代码覆盖率报告 - 使用传统语法
if (fileExists('target/site/jacoco/jacoco.xml')) {
publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_LAST_BUILD') } else if (fileExists('target/jacoco.exec')) {
echo '⚠️ 发现jacoco.exec文件但推荐使用XML格式的覆盖率报告'
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/site/jacoco',
reportFiles: 'index.html',
reportName: 'JaCoCo Coverage Report'
])
echo '✅ JaCoCo覆盖率报告已发布'
} else if (fileExists('target/jacoco.exec')) {
echo '✅ JaCoCo执行文件已生成: target/jacoco.exec'
} else {
echo '⚠️ 未找到JaCoCo覆盖率报告文件'
}