diff --git a/Jenkinsfile b/Jenkinsfile index c56248a..d0c7a97 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,12 +55,23 @@ pipeline { always { script { // 检查测试报告文件是否存在 - def reportFiles = findFiles(glob: 'target/surefire-reports/TEST-*.xml') - if (reportFiles.length > 0) { - echo "找到 ${reportFiles.length} 个测试报告文件" - junit testResults: 'target/surefire-reports/TEST-*.xml' + def testReportDir = 'target/surefire-reports' + def hasReportDir = fileExists testReportDir + + if (hasReportDir) { + def reportCount = sh( + script: "find ${testReportDir} -name 'TEST-*.xml' | wc -l", + returnStdout: true + ).trim() as int + + if (reportCount > 0) { + echo "找到 ${reportCount} 个测试报告文件" + junit testResults: 'target/surefire-reports/TEST-*.xml' + } else { + echo "未找到测试报告文件,跳过JUnit发布" + } } else { - echo "未找到测试报告文件,跳过JUnit发布" + echo "未找到测试报告目录,跳过JUnit发布" } } } @@ -311,4 +322,4 @@ volumes: mysql_data: minio_data: """ -} \ No newline at end of file +}