fix(ci): keep Jenkins boolean continuations parseable

This commit is contained in:
2026-08-24 17:37:36 +08:00
parent bb74a05562
commit a320198b47
4 changed files with 16 additions and 11 deletions
Vendored
+4 -4
View File
@@ -154,8 +154,8 @@ pipeline {
if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) { if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) {
error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS') error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS')
} }
if (['BOTH', 'SELECT'].contains(bridgeRegion) if (['BOTH', 'SELECT'].contains(bridgeRegion) &&
&& !['development', 'test'].contains(env.RESOLVED_ENVIRONMENT)) { !['development', 'test'].contains(env.RESOLVED_ENVIRONMENT)) {
error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS') error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS')
} }
if (bridgeRegion == 'SELECT') { if (bridgeRegion == 'SELECT') {
@@ -229,8 +229,8 @@ pipeline {
String service = selectedService String service = selectedService
branches[service] = { branches[service] = {
String jobName = "${env.RESOLVED_JOB_PREFIX}${service}" String jobName = "${env.RESOLVED_JOB_PREFIX}${service}"
boolean deployBothBridges = service == 'event-bridge-service' boolean deployBothBridges = service == 'event-bridge-service' &&
&& ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION) ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION)
String downstreamImageTag = deployBothBridges String downstreamImageTag = deployBothBridges
? "${env.IMAGE_TAG}-both" ? "${env.IMAGE_TAG}-both"
: env.IMAGE_TAG : env.IMAGE_TAG
+7 -7
View File
@@ -76,8 +76,8 @@ pipeline {
if (!serviceModules.contains(service)) { if (!serviceModules.contains(service)) {
error("无法从 Job 名称 ${env.JOB_BASE_NAME} 识别服务;名称必须以以下服务之一结尾: ${serviceModules.join(', ')}") error("无法从 Job 名称 ${env.JOB_BASE_NAME} 识别服务;名称必须以以下服务之一结尾: ${serviceModules.join(', ')}")
} }
boolean deployBothBridges = service == 'event-bridge-service' boolean deployBothBridges = service == 'event-bridge-service' &&
&& imageTag?.endsWith('-both') imageTag?.endsWith('-both')
if (deployBothBridges) { if (deployBothBridges) {
imageTag = imageTag.substring(0, imageTag.length() - '-both'.length()) imageTag = imageTag.substring(0, imageTag.length() - '-both'.length())
} }
@@ -105,8 +105,8 @@ pipeline {
if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) { if (!['BOTH', 'SELECT', 'CN', 'OVERSEAS'].contains(bridgeRegion)) {
error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS') error('EVENT_BRIDGE_REGION 只能为 BOTH、CN 或 OVERSEAS')
} }
if ((deployBothBridges || ['BOTH', 'SELECT'].contains(bridgeRegion)) if ((deployBothBridges || ['BOTH', 'SELECT'].contains(bridgeRegion)) &&
&& !['development', 'test'].contains(params.ENVIRONMENT)) { !['development', 'test'].contains(params.ENVIRONMENT)) {
error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS') error('事件桥 BOTH 仅支持开发或测试环境;预发布和生产必须明确选择 CN 或 OVERSEAS')
} }
} }
@@ -202,9 +202,9 @@ pipeline {
try { try {
unstash 'deployment-files' unstash 'deployment-files'
echo "在目标节点 ${env.NODE_NAME} 本机部署到 ${params.ENVIRONMENT}" echo "在目标节点 ${env.NODE_NAME} 本机部署到 ${params.ENVIRONMENT}"
List bridgeRegions = env.RESOLVED_SERVICE == 'event-bridge-service' List bridgeRegions = (env.RESOLVED_SERVICE == 'event-bridge-service' &&
&& (env.DEPLOY_BOTH_EVENT_BRIDGES == 'true' (env.DEPLOY_BOTH_EVENT_BRIDGES == 'true' ||
|| ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION)) ['BOTH', 'SELECT'].contains(params.EVENT_BRIDGE_REGION)))
? ['CN', 'OVERSEAS'] ? ['CN', 'OVERSEAS']
: [params.EVENT_BRIDGE_REGION] : [params.EVENT_BRIDGE_REGION]
withCredentials([ withCredentials([
@@ -11,6 +11,7 @@ test('coordinator releases its builder while waiting for downstream jobs', () =>
assert.match(pipeline, /agent \{ label 'java-builder' \}/) assert.match(pipeline, /agent \{ label 'java-builder' \}/)
assert.doesNotMatch(pipeline, /agent any/) assert.doesNotMatch(pipeline, /agent any/)
assert.doesNotMatch(pipeline, /cleanWs\(/) assert.doesNotMatch(pipeline, /cleanWs\(/)
assert.doesNotMatch(pipeline, /^\s*(?:&&|\|\|)/m)
}) })
test('coordinator runs selected tests once before parallel service packaging', () => { test('coordinator runs selected tests once before parallel service packaging', () => {
@@ -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')) const serviceDockerfile = (await readFile(new URL('../deploy/docker/Dockerfile', import.meta.url), 'utf8'))
.replaceAll('\r\n', '\n') .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', () => { test('test deployments compile packages without rerunning the full unit test suite', () => {
assert.match(pipeline, /params\.ENVIRONMENT == 'test' \|\| params\.SKIP_TESTS/) assert.match(pipeline, /params\.ENVIRONMENT == 'test' \|\| params\.SKIP_TESTS/)
assert.match(pipeline, /skipTestExecution \? '-DskipTests' : ''/) assert.match(pipeline, /skipTestExecution \? '-DskipTests' : ''/)