diff --git a/Jenkinsfile b/Jenkinsfile index 0660d219a..b8084642e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -154,8 +154,8 @@ pipeline { if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) { error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS') } - if (['BOTH', 'SELECT'].contains(bridgeRegion) - && !['development', 'test'].contains(env.RESOLVED_ENVIRONMENT)) { + if (['BOTH', 'SELECT'].contains(bridgeRegion) && + !['development', 'test'].contains(env.RESOLVED_ENVIRONMENT)) { error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS') } if (bridgeRegion == 'SELECT') { @@ -229,8 +229,8 @@ pipeline { String service = selectedService branches[service] = { String jobName = "${env.RESOLVED_JOB_PREFIX}${service}" - boolean deployBothBridges = service == 'event-bridge-service' - && ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION) + boolean deployBothBridges = service == 'event-bridge-service' && + ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION) String downstreamImageTag = deployBothBridges ? "${env.IMAGE_TAG}-both" : env.IMAGE_TAG diff --git a/Jenkinsfile.service b/Jenkinsfile.service index a1aed8754..72b8e5f43 100644 --- a/Jenkinsfile.service +++ b/Jenkinsfile.service @@ -76,8 +76,8 @@ pipeline { if (!serviceModules.contains(service)) { error("无法从 Job 名称 ${env.JOB_BASE_NAME} 识别服务;名称必须以以下服务之一结尾: ${serviceModules.join(', ')}") } - boolean deployBothBridges = service == 'event-bridge-service' - && imageTag?.endsWith('-both') + boolean deployBothBridges = service == 'event-bridge-service' && + imageTag?.endsWith('-both') if (deployBothBridges) { imageTag = imageTag.substring(0, imageTag.length() - '-both'.length()) } @@ -105,8 +105,8 @@ pipeline { if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) { error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS') } - if ((deployBothBridges || ['BOTH', 'SELECT'].contains(bridgeRegion)) - && !['development', 'test'].contains(params.ENVIRONMENT)) { + if ((deployBothBridges || ['BOTH', 'SELECT'].contains(bridgeRegion)) && + !['development', 'test'].contains(params.ENVIRONMENT)) { error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS') } } @@ -202,9 +202,9 @@ pipeline { try { unstash 'deployment-files' echo "在目标节点 ${env.NODE_NAME} 本机部署到 ${params.ENVIRONMENT}" - List bridgeRegions = env.RESOLVED_SERVICE == 'event-bridge-service' - && (env.DEPLOY_BOTH_EVENT_BRIDGES == 'true' - || ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION)) + List bridgeRegions = (env.RESOLVED_SERVICE == 'event-bridge-service' && + (env.DEPLOY_BOTH_EVENT_BRIDGES == 'true' || + ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION))) ? ['CN', 'OVERSEAS'] : [params.EVENT_BRIDGE_REGION] withCredentials([ diff --git a/scripts/controller-pipeline-contract.test.mjs b/scripts/controller-pipeline-contract.test.mjs index 65be87496..2248b09e6 100644 --- a/scripts/controller-pipeline-contract.test.mjs +++ b/scripts/controller-pipeline-contract.test.mjs @@ -11,6 +11,7 @@ test('coordinator releases its builder while waiting for downstream jobs', () => assert.match(pipeline, /agent \{ label 'java-builder' \}/) assert.doesNotMatch(pipeline, /agent any/) assert.doesNotMatch(pipeline, /cleanWs\(/) + assert.doesNotMatch(pipeline, /^\s*(?:&&|\|\|)/m) }) test('coordinator runs selected tests once before parallel service packaging', () => { diff --git a/scripts/test-environment-pipeline-contract.test.mjs b/scripts/test-environment-pipeline-contract.test.mjs index 9858d6992..cb7a9566c 100644 --- a/scripts/test-environment-pipeline-contract.test.mjs +++ b/scripts/test-environment-pipeline-contract.test.mjs @@ -13,6 +13,10 @@ const ciMavenSettings = (await readFile(new URL('../deploy/maven/settings-ci.xml const serviceDockerfile = (await readFile(new URL('../deploy/docker/Dockerfile', import.meta.url), 'utf8')) .replaceAll('\r\n', '\n') +test('service pipeline keeps boolean operators on parseable Groovy continuation lines', () => { + assert.doesNotMatch(pipeline, /^\s*(?:&&|\|\|)/m) +}) + test('test deployments compile packages without rerunning the full unit test suite', () => { assert.match(pipeline, /params\.ENVIRONMENT == 'test' \|\| params\.SKIP_TESTS/) assert.match(pipeline, /skipTestExecution \? '-DskipTests' : ''/)