Commit a7e0df29 a7e0df29db0fea314a62bd98d1a9727695002b88 by chenjing

更新配置

1 parent 599f8c77
Showing 1 changed file with 27 additions and 11 deletions
......@@ -85,30 +85,46 @@ pipeline {
post {
always {
echo "正在收集测试结果..."
// 列出所有报告文件(调试用)
sh '''
echo "=== 报告文件清单 ==="
if [ -d "reports" ]; then
find reports -type f -name "*.html" -o -name "*.xlsx" | sort
else
echo "reports 目录不存在"
fi
echo "===================="
'''
// 归档报告文件
archiveArtifacts artifacts: 'reports/**/*.{html,xlsx}',
archiveArtifacts artifacts: 'reports/**/*',
allowEmptyArchive: true,
defaultExcludes: false
fingerprint: true
// 发布 HTML 报告到 Jenkins
script {
def reportDir = "reports/${env.DEPLOY_ENV}"
def htmlReports = sh(
script: "find ${reportDir} -maxdepth 1 -name '*.html' -type f | sort -r | head -1",
sh "ls -la ${reportDir} 2>/dev/null || echo 'Directory not found'"
def htmlFile = sh(
script: "find ${reportDir} -maxdepth 1 -name '*.html' -type f 2>/dev/null | sort -r | head -1 | xargs basename",
returnStdout: true
).trim()
if (htmlReports) {
echo "找到最新HTML报告: ${htmlReports}"
if (htmlFile) {
echo "找到HTML报告: ${htmlFile}"
publishHTML([
reportDir: '.',
reportFiles: htmlReports,
reportName: "API Test Report (${env.DEPLOY_ENV})",
reportDir: reportDir,
reportFiles: htmlFile,
reportName: "Test Report [${env.DEPLOY_ENV}]",
keepAll: true,
alwaysLinkToLastBuild: true
alwaysLinkToLastBuild: true,
allowMissing: false
])
echo "HTML报告已发布到Jenkins"
} else {
echo "未找到HTML报告文件"
echo "警告: 未找到HTML报告文件 (路径: ${reportDir})"
}
}
}
......