From 52b673b8789f8a8d1047558942b4172dcd152995 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 22 Aug 2026 17:46:11 +0800 Subject: [PATCH] perf(ci): release coordinator builder executor --- Jenkinsfile | 12 ++++++++---- scripts/controller-pipeline-contract.test.mjs | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5544ff9e0..389450309 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,7 +36,7 @@ def environmentChoicesForJob(String jobBaseName) { pipeline { // 总控流水线只识别变更并调度独立的服务 Job;实际 Maven、镜像和部署在 Jenkinsfile.service 中完成。 - agent { label 'java-builder' } + agent none options { disableConcurrentBuilds() @@ -69,6 +69,7 @@ pipeline { stages { stage('确定构建范围') { + agent { label 'java-builder' } steps { script { // 开发环境总控 Job 固定部署到 development,避免首次构建沿用 ENVIRONMENT 的默认 test 值。 @@ -151,6 +152,11 @@ pipeline { } } } + post { + always { + cleanWs(deleteDirs: true, notFailBuild: true) + } + } } stage('生产环境部署确认(仅 production 执行)') { @@ -170,6 +176,7 @@ pipeline { expression { env.RESOLVED_ENVIRONMENT == 'test' && params.INITIALIZE_TEST_DATABASE } } } + agent { label 'java-test' } steps { sh 'sh deploy/scripts/initialize-test-databases.sh' } @@ -225,7 +232,4 @@ pipeline { } } - post { - always { cleanWs(deleteDirs: true, notFailBuild: true) } - } } diff --git a/scripts/controller-pipeline-contract.test.mjs b/scripts/controller-pipeline-contract.test.mjs index 48a20a75c..7e0758505 100644 --- a/scripts/controller-pipeline-contract.test.mjs +++ b/scripts/controller-pipeline-contract.test.mjs @@ -5,9 +5,12 @@ import test from 'node:test' const pipeline = (await readFile(new URL('../Jenkinsfile', import.meta.url), 'utf8')) .replaceAll('\r\n', '\n') -test('coordinator runs only on the shared Java builder pool', () => { +test('coordinator releases its builder while waiting for downstream jobs', () => { + assert.match(pipeline, /pipeline \{[\s\S]*?agent none/) + assert.match(pipeline, /stage\('确定构建范围'\) \{[\s\S]*?agent \{ label 'java-builder' \}/) assert.match(pipeline, /agent \{ label 'java-builder' \}/) assert.doesNotMatch(pipeline, /agent any/) + assert.doesNotMatch(pipeline, /post \{\s*always \{ cleanWs[\s\S]*?\}\s*\}\s*\}\s*$/) }) test('AUTO detects database migrations without expanding them to all services', () => {