Commit 599f8c77 599f8c77f4aa406f34dc6cc1166fad5f73624859 by chenjing

更新配置

1 parent c0b8d771
...@@ -75,7 +75,8 @@ pipeline { ...@@ -75,7 +75,8 @@ pipeline {
75 steps { 75 steps {
76 echo "正在生成测试报告..." 76 echo "正在生成测试报告..."
77 sh ''' 77 sh '''
78 ls -la api_test_report_* 2>/dev/null || echo "未找到报告文件" 78 echo "查找报告文件..."
79 ls -lh reports/${DEPLOY_ENV}/ 2>/dev/null || echo "未找到报告文件"
79 ''' 80 '''
80 } 81 }
81 } 82 }
...@@ -83,16 +84,42 @@ pipeline { ...@@ -83,16 +84,42 @@ pipeline {
83 84
84 post { 85 post {
85 always { 86 always {
86 echo "清理工作目录..." 87 echo "正在收集测试结果..."
87 sh 'echo "测试执行完成"' 88 // 归档报告文件
89 archiveArtifacts artifacts: 'reports/**/*.{html,xlsx}',
90 allowEmptyArchive: true,
91 defaultExcludes: false
92
93 // 发布 HTML 报告到 Jenkins
94 script {
95 def reportDir = "reports/${env.DEPLOY_ENV}"
96 def htmlReports = sh(
97 script: "find ${reportDir} -maxdepth 1 -name '*.html' -type f | sort -r | head -1",
98 returnStdout: true
99 ).trim()
100
101 if (htmlReports) {
102 echo "找到最新HTML报告: ${htmlReports}"
103 publishHTML([
104 reportDir: '.',
105 reportFiles: htmlReports,
106 reportName: "API Test Report (${env.DEPLOY_ENV})",
107 keepAll: true,
108 alwaysLinkToLastBuild: true
109 ])
110 } else {
111 echo "未找到HTML报告文件"
112 }
113 }
88 } 114 }
89 115
90 success { 116 success {
91 echo " [${DEPLOY_ENV}环境] 所有测试用例运行成功!" 117 echo "[SUCCESS] [${DEPLOY_ENV}环境] 所有测试用例运行成功!"
92 } 118 }
93 119
94 failure { 120 failure {
95 echo " [${DEPLOY_ENV}环境] 有测试用例执行失败!" 121 echo "[FAILURE] [${DEPLOY_ENV}环境] 有测试用例执行失败!"
96 } 122 }
97 } 123 }
98 } 124 }
125
......