diff --git a/Jenkinsfile b/Jenkinsfile index 1c944c197..cedb33e92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -295,6 +295,7 @@ pipeline { echo "统一测试本次选中的服务及其公共依赖: ${selectedModules}" sh """ test \"\$(git rev-parse HEAD)\" = \"${env.SOURCE_COMMIT}\" + find . -type f -path '*/target/surefire-reports/TEST-*.xml' -delete mvn --settings deploy/maven/settings-ci.xml --batch-mode --errors -pl ${selectedModules} -am test """ echo "统一测试门禁通过: ${env.SOURCE_COMMIT};下游单服务任务不再重复执行测试" diff --git a/scripts/controller-pipeline-contract.test.mjs b/scripts/controller-pipeline-contract.test.mjs index 9ee3dd23c..8b5ce4608 100644 --- a/scripts/controller-pipeline-contract.test.mjs +++ b/scripts/controller-pipeline-contract.test.mjs @@ -17,10 +17,17 @@ test('coordinator releases its builder while waiting for downstream jobs', () => test('coordinator runs selected tests once before parallel service packaging', () => { const gateIndex = pipeline.indexOf("stage('统一 Maven 测试门禁')") const dispatchIndex = pipeline.indexOf("stage('并行调度独立服务 Job')") + const staleReportCleanupIndex = pipeline.indexOf( + "find . -type f -path '*/target/surefire-reports/TEST-*.xml' -delete" + ) + const selectedTestIndex = pipeline.indexOf('-pl ${selectedModules} -am test') assert.ok(gateIndex >= 0, 'unified test gate must exist') assert.ok(dispatchIndex > gateIndex, 'unified tests must finish before downstream dispatch') + assert.ok(staleReportCleanupIndex > gateIndex, 'stale Surefire reports must be removed inside the test gate') + assert.ok(selectedTestIndex > staleReportCleanupIndex, 'stale reports must be removed before selected tests run') assert.match(pipeline, /-pl \$\{selectedModules\} -am test/) + assert.match(pipeline, /junit allowEmptyResults: true, testResults: '\*\*\/target\/surefire-reports\/TEST-\*\.xml'/) assert.match(pipeline, /booleanParam\(name: 'SKIP_TESTS', value: true\)/) assert.doesNotMatch(pipeline, /TESTED_COMMIT/) })