From 194442170e5330067fe6a8006948abb1d39738c9 Mon Sep 17 00:00:00 2001 From: wangtianqi <1350217033@qq.com> Date: Mon, 23 Jun 2025 21:58:12 +0800 Subject: [PATCH] fix: replace jacocoAdapter with publishHTML for Jenkins compatibility --- Jenkinsfile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c02dc3d..7405c28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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覆盖率报告文件' }