Commit a7e0df29 a7e0df29db0fea314a62bd98d1a9727695002b88 by chenjing

更新配置

1 parent 599f8c77
Showing 1 changed file with 27 additions and 11 deletions
...@@ -85,30 +85,46 @@ pipeline { ...@@ -85,30 +85,46 @@ pipeline {
85 post { 85 post {
86 always { 86 always {
87 echo "正在收集测试结果..." 87 echo "正在收集测试结果..."
88
89 // 列出所有报告文件(调试用)
90 sh '''
91 echo "=== 报告文件清单 ==="
92 if [ -d "reports" ]; then
93 find reports -type f -name "*.html" -o -name "*.xlsx" | sort
94 else
95 echo "reports 目录不存在"
96 fi
97 echo "===================="
98 '''
99
88 // 归档报告文件 100 // 归档报告文件
89 archiveArtifacts artifacts: 'reports/**/*.{html,xlsx}', 101 archiveArtifacts artifacts: 'reports/**/*',
90 allowEmptyArchive: true, 102 allowEmptyArchive: true,
91 defaultExcludes: false 103 fingerprint: true
92 104
93 // 发布 HTML 报告到 Jenkins 105 // 发布 HTML 报告到 Jenkins
94 script { 106 script {
95 def reportDir = "reports/${env.DEPLOY_ENV}" 107 def reportDir = "reports/${env.DEPLOY_ENV}"
96 def htmlReports = sh( 108 sh "ls -la ${reportDir} 2>/dev/null || echo 'Directory not found'"
97 script: "find ${reportDir} -maxdepth 1 -name '*.html' -type f | sort -r | head -1", 109
110 def htmlFile = sh(
111 script: "find ${reportDir} -maxdepth 1 -name '*.html' -type f 2>/dev/null | sort -r | head -1 | xargs basename",
98 returnStdout: true 112 returnStdout: true
99 ).trim() 113 ).trim()
100 114
101 if (htmlReports) { 115 if (htmlFile) {
102 echo "找到最新HTML报告: ${htmlReports}" 116 echo "找到HTML报告: ${htmlFile}"
103 publishHTML([ 117 publishHTML([
104 reportDir: '.', 118 reportDir: reportDir,
105 reportFiles: htmlReports, 119 reportFiles: htmlFile,
106 reportName: "API Test Report (${env.DEPLOY_ENV})", 120 reportName: "Test Report [${env.DEPLOY_ENV}]",
107 keepAll: true, 121 keepAll: true,
108 alwaysLinkToLastBuild: true 122 alwaysLinkToLastBuild: true,
123 allowMissing: false
109 ]) 124 ])
125 echo "HTML报告已发布到Jenkins"
110 } else { 126 } else {
111 echo "未找到HTML报告文件" 127 echo "警告: 未找到HTML报告文件 (路径: ${reportDir})"
112 } 128 }
113 } 129 }
114 } 130 }
......