diff --git a/Jenkinsfile b/Jenkinsfile index 132b7cb95..07fb4d420 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,6 +37,12 @@ def environmentChoicesForJob(String jobBaseName) { : ['test', 'development', 'staging', 'production'] } +def downstreamJobPrefixForJob(String jobBaseName) { + return jobBaseName == 'backend-java-dev' + ? 'baiyue-firstleg-dev-' + : 'baiyue-firstleg-' +} + pipeline { // 总控流水线只识别变更并调度独立的服务 Job;实际 Maven、镜像和部署在 Jenkinsfile.service 中完成。 agent any @@ -71,7 +77,7 @@ pipeline { booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: '是否跳过测试;生产构建不建议勾选') string(name: 'IMAGE_REPOSITORY', defaultValue: '172.31.198.7:10082/java-project/baiyue-firstleg', description: '内网共享镜像仓库地址') string(name: 'DOCKER_BASE_IMAGE', defaultValue: 'docker.m.daocloud.io/library/eclipse-temurin:17-jre-alpine', description: 'Java 17 基础镜像') - string(name: 'DOWNSTREAM_JOB_PREFIX', defaultValue: 'baiyue-firstleg-', description: '单服务 Jenkins Job 名称前缀,例如 baiyue-firstleg-auth') + string(name: 'DOWNSTREAM_JOB_PREFIX', defaultValue: downstreamJobPrefixForJob(env.JOB_BASE_NAME), description: '单服务 Jenkins Job 名称前缀;开发总控自动使用 dev 专属 Job') } stages { diff --git a/scripts/test-environment-pipeline-contract.test.mjs b/scripts/test-environment-pipeline-contract.test.mjs index f1369963d..1e074dfbd 100644 --- a/scripts/test-environment-pipeline-contract.test.mjs +++ b/scripts/test-environment-pipeline-contract.test.mjs @@ -23,6 +23,8 @@ test('coordinator jobs present their own deployment environment as the default c assert.match(coordinatorPipeline, /\? \['development', 'test', 'staging', 'production'\]/) assert.match(coordinatorPipeline, /: \['test', 'development', 'staging', 'production'\]/) assert.match(coordinatorPipeline, /environmentChoicesForJob\(env\.JOB_BASE_NAME\)/) + assert.match(coordinatorPipeline, /jobBaseName == 'backend-java-dev'[\s\S]*?'baiyue-firstleg-dev-'/) + assert.match(coordinatorPipeline, /downstreamJobPrefixForJob\(env\.JOB_BASE_NAME\)/) }) test('production deployments cannot skip tests', () => {