From 94595c810bb193b831423971503304cfa03614fc Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Wed, 21 Oct 2026 15:28:44 +0800 Subject: [PATCH] fix(ci): retain configured image repository defaults --- Jenkinsfile | 3 ++- Jenkinsfile.service | 3 ++- scripts/test-environment-pipeline-contract.test.mjs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 01e5992d5..030b6c755 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,7 +161,8 @@ pipeline { choice(name: 'ENVIRONMENT', choices: environmentChoicesForJob(env.JOB_BASE_NAME), description: '部署环境') booleanParam(name: 'DEPLOY', defaultValue: false, description: '各服务构建成功后是否独立部署') booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: '是否跳过测试执行(仍编译测试源码)') - string(name: 'IMAGE_REPOSITORY', defaultValue: '', description: '必须填写已核实的共享镜像仓库地址 host[:port]/owner/image') + // 地址由当前 Job 配置提供;参数声明刷新时保留已配置值,不将环境地址写入源码。 + string(name: 'IMAGE_REPOSITORY', defaultValue: params.IMAGE_REPOSITORY ?: '', description: '沿用当前 Job 已配置的镜像仓库地址;首次配置或更换仓库时填写 host[:port]/owner/image') string(name: 'DOCKER_BASE_IMAGE', defaultValue: 'eclipse-temurin:17-jre-alpine', description: 'Java 17 基础镜像') choice(name: 'DOWNSTREAM_JOB_PREFIX', choices: downstreamJobPrefixChoicesForJob(env.JOB_BASE_NAME), description: '由当前总控 Job 固定的单服务 Job 前缀') } diff --git a/Jenkinsfile.service b/Jenkinsfile.service index a83e45409..7693a915d 100644 --- a/Jenkinsfile.service +++ b/Jenkinsfile.service @@ -49,7 +49,8 @@ pipeline { booleanParam(name: 'ALLOW_SAME_CONTRACT_ROLLBACK', defaultValue: false, description: '仅确认相同协议与Schema时允许回滚;架构切换保持关闭') booleanParam(name: 'DEPLOY', defaultValue: false, description: '构建成功后是否部署本服务') booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: '是否跳过测试') - string(name: 'IMAGE_REPOSITORY', defaultValue: '', description: '必须填写已核实的共享镜像仓库基础路径,不包含服务名和标签') + // 独立构建沿用本 Job 配置,总控调度时保留其明确传入的地址。 + string(name: 'IMAGE_REPOSITORY', defaultValue: params.IMAGE_REPOSITORY ?: '', description: '沿用当前 Job 已配置的镜像仓库基础路径,不包含服务名和标签;首次配置或更换仓库时填写') string(name: 'DOCKER_BASE_IMAGE', defaultValue: 'eclipse-temurin:17-jre-alpine', description: 'Java 17 基础镜像') } diff --git a/scripts/test-environment-pipeline-contract.test.mjs b/scripts/test-environment-pipeline-contract.test.mjs index e27d65b98..9ad321f05 100644 --- a/scripts/test-environment-pipeline-contract.test.mjs +++ b/scripts/test-environment-pipeline-contract.test.mjs @@ -17,7 +17,8 @@ const serviceCompose = (await readFile(new URL('../deploy/docker-compose.yml', i test('both pipelines reject the placeholder registry from failed build 662 before Maven or Docker', () => { for (const source of [coordinatorPipeline, pipeline]) { - assert.match(source, /string\(name: 'IMAGE_REPOSITORY', defaultValue: ''/) + assert.match(source, /string\(name: 'IMAGE_REPOSITORY', defaultValue: params\.IMAGE_REPOSITORY \?: ''/, + 'declarative parameter refresh must retain this job\'s configured registry instead of resetting it') const guard = source.match(/(?:requestedRepository|imageRepository)\.tokenize\('\/'\)\[0\] ==~ \/\(\?i\)([^\n]+)\//) assert.ok(guard, 'registry host must reject reserved example domains') const reservedHost = new RegExp(`^(?:${guard[1]})$`, 'i')