From a3e0279d8d78d72010dd75c01091f3bb5506d927 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Tue, 17 Dec 2024 16:54:45 +0800 Subject: [PATCH 01/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/UserPipelineTriggerEventResource.kt | 18 ++++++++++++++++ .../process/constant/ProcessMessageCode.kt | 1 + .../UserPipelineTriggerEventResourceImpl.kt | 15 +++++++++++++ .../process/dao/PipelineTriggerEventDao.kt | 9 ++++++++ .../trigger/PipelineTriggerEventService.kt | 21 +++++++++++++++++++ .../i18n/process/message_en_US.properties | 1 + .../i18n/process/message_zh_CN.properties | 1 + 7 files changed, 66 insertions(+) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt index 3c672ddf7498..dde60e2ce688 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt @@ -250,4 +250,22 @@ interface UserPipelineTriggerEventResource { @PathParam("eventId") eventId: Long ): Result + + @Operation(summary = "回放指定构建任务的触发事件") + @POST + @Path("/{projectId}/{pipelineId}/{buildId}/replayByBuild") + fun replayByBuild( + @Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @Parameter(description = "项目ID", required = true) + @PathParam("projectId") + projectId: String, + @Parameter(description = "流水线ID", required = true) + @PathParam("pipelineId") + pipelineId: String, + @Parameter(description = "构建ID", required = true) + @PathParam("buildId") + buildId: String + ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index 95d527275a86..471abfc526a2 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -362,6 +362,7 @@ object ProcessMessageCode { const val ERROR_PIPELINE_BUILD_START_PARAM_NO_EMPTY = "2101254" // 构建启动参数如果必填,不能为空 const val ERROR_REPEATEDLY_START_VM = "2101255" // 重复启动构建机,当前构建机的状态为:{0} const val ERROR_PIPELINE_VARIABLES_OUT_OF_LENGTH = "2101256" // 流水线启动参数{0}超出4000长度限制 + const val ERROR_WEBHOOK_EVENT_NOT_FOUND = "2101258" // webhook 触发记录不存在 const val BK_SUCCESSFULLY_DISTRIBUTED = "bkSuccessfullyDistributed" // 跨项目构件分发成功,共分发了{0}个文件 const val BK_SUCCESSFULLY_FAILED = "bkSuccessfullyFailed" // 跨项目构件分发失败, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt index 6d88857ec3dc..565da9d0ab92 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt @@ -213,4 +213,19 @@ class UserPipelineTriggerEventResourceImpl( ) ) } + + override fun replayByBuild( + userId: String, + projectId: String, + pipelineId: String, + buildId: String + ): Result { + pipelineTriggerEventService.replayByBuild( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId + ) + return Result(true) + } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt index 9ea38ff78850..02a925fc2528 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt @@ -695,4 +695,13 @@ class PipelineTriggerEventDao { } } } + + fun getEventIdByBuildId(dslContext: DSLContext, projectId: String, buildId: String): Long? { + return with(T_PIPELINE_TRIGGER_DETAIL) { + dslContext.select(EVENT_ID) + .from(this) + .where(PROJECT_ID.eq(projectId).and(BUILD_ID.eq(buildId))) + .fetchOne()?.value1() + } + } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt index 1f981c12a487..7d02cd068403 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt @@ -452,6 +452,27 @@ class PipelineTriggerEventService @Autowired constructor( ) } + fun replayByBuild( + userId: String, + projectId: String, + pipelineId: String, + buildId: String + ) { + val eventId = pipelineTriggerEventDao.getEventIdByBuildId( + dslContext = dslContext, + projectId = projectId, + buildId = buildId + ) ?: throw ErrorCodeException( + errorCode = ProcessMessageCode.ERROR_WEBHOOK_EVENT_NOT_FOUND + ) + replayAll( + userId = userId, + projectId = projectId, + eventId = eventId, + pipelineId = pipelineId + ) + } + /** * 获取国际化构建事件描述 */ diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index ec2298e4ab74..da51e3acb50b 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -248,6 +248,7 @@ 2101254=Parameter {0} is required and cannot be empty 2101255=Start the build machine repeatedly. The current status of the build machine is: {0} 2101256=pipeline build parameter {0} value exceeds 4000 length limit +2101258=Webhook trigger event does not exist ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### # 公共变量 diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index 643e85bda27f..dd353cd35876 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -248,6 +248,7 @@ 2101254=构建入参[{0}]必填,不能为空 2101255=重复启动构建机,当前构建机的状态为:{0} 2101256=流水线变量{0}值超出4000长度限制 +2101258=Webhook触发记录不存在 ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### ci.build-no=构建号,开启推荐版本号时有效 From b7468934900e369f2edc306b30251ab8574845c1 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 27 Dec 2024 17:35:28 +0800 Subject: [PATCH 02/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/user/UserBuildResource.kt | 18 ++++++++++ .../user/UserPipelineTriggerEventResource.kt | 18 ---------- .../process/api/UserBuildResourceImpl.kt | 15 ++++++++ .../UserPipelineTriggerEventResourceImpl.kt | 15 -------- .../builds/PipelineBuildFacadeService.kt | 35 +++++++++++++++++++ 5 files changed, 68 insertions(+), 33 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt index fd9a3526ed86..b4b8ad48c75e 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt @@ -701,4 +701,22 @@ interface UserBuildResource { @QueryParam("stageId") stageId: String ): Result + + @Operation(summary = "回放指定构建任务的触发事件") + @POST + @Path("/{projectId}/{pipelineId}/{buildId}/replayByBuild") + fun replayByBuild( + @Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @Parameter(description = "项目ID", required = true) + @PathParam("projectId") + projectId: String, + @Parameter(description = "流水线ID", required = true) + @PathParam("pipelineId") + pipelineId: String, + @Parameter(description = "构建ID", required = true) + @PathParam("buildId") + buildId: String + ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt index dde60e2ce688..3c672ddf7498 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserPipelineTriggerEventResource.kt @@ -250,22 +250,4 @@ interface UserPipelineTriggerEventResource { @PathParam("eventId") eventId: Long ): Result - - @Operation(summary = "回放指定构建任务的触发事件") - @POST - @Path("/{projectId}/{pipelineId}/{buildId}/replayByBuild") - fun replayByBuild( - @Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE) - @HeaderParam(AUTH_HEADER_USER_ID) - userId: String, - @Parameter(description = "项目ID", required = true) - @PathParam("projectId") - projectId: String, - @Parameter(description = "流水线ID", required = true) - @PathParam("pipelineId") - pipelineId: String, - @Parameter(description = "构建ID", required = true) - @PathParam("buildId") - buildId: String - ): Result } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index a269d560e491..b6e24e2b3b0a 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -635,6 +635,21 @@ class UserBuildResourceImpl @Autowired constructor( ) } + override fun replayByBuild( + userId: String, + projectId: String, + pipelineId: String, + buildId: String + ): Result { + pipelineBuildFacadeService.replayBuild( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + userId = userId + ) + return Result(true) + } + private fun checkParam(userId: String, projectId: String, pipelineId: String) { if (userId.isBlank()) { throw ParamBlankException("Invalid userId") diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt index 565da9d0ab92..6d88857ec3dc 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserPipelineTriggerEventResourceImpl.kt @@ -213,19 +213,4 @@ class UserPipelineTriggerEventResourceImpl( ) ) } - - override fun replayByBuild( - userId: String, - projectId: String, - pipelineId: String, - buildId: String - ): Result { - pipelineTriggerEventService.replayByBuild( - userId = userId, - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId - ) - return Result(true) - } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index e678d6543198..fbb87d185696 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2687,6 +2687,41 @@ class PipelineBuildFacadeService( ) } + fun replayBuild( + projectId: String, + pipelineId: String, + buildId: String, + userId: String + ) { + pipelinePermissionService.validPipelinePermission( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + permission = AuthPermission.EXECUTE, + message = MessageUtil.getMessageByLocale( + CommonMessageCode.USER_NOT_PERMISSIONS_OPERATE_PIPELINE, + I18nUtil.getLanguage(userId), + arrayOf( + userId, + projectId, + AuthPermission.EXECUTE.getI18n(I18nUtil.getLanguage(userId)), + pipelineId + ) + ) + ) + val buildInfo = checkPipelineInfo(projectId, pipelineId, buildId) + // 目标构建已经结束,直接按原有启动参数新发起一次构建,此次构建会遵循流水线配置的串行阈值 + if (!buildInfo.status.isFinish()) { + logger.info("build is not finished, buildId: $buildId") + return + } + buildRestartPipeline( + projectId = projectId, + pipelineId = pipelineId, + buildInfo = buildInfo + ) + } + private fun buildRestartPipeline( projectId: String, pipelineId: String, From a31035541fa4ed954556ada3683746aa40498aae Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 27 Dec 2024 17:38:19 +0800 Subject: [PATCH 03/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/constant/ProcessMessageCode.kt | 1 - .../process/dao/PipelineTriggerEventDao.kt | 9 -------- .../trigger/PipelineTriggerEventService.kt | 21 ------------------- .../i18n/process/message_en_US.properties | 1 - .../i18n/process/message_zh_CN.properties | 1 - 5 files changed, 33 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index 471abfc526a2..95d527275a86 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -362,7 +362,6 @@ object ProcessMessageCode { const val ERROR_PIPELINE_BUILD_START_PARAM_NO_EMPTY = "2101254" // 构建启动参数如果必填,不能为空 const val ERROR_REPEATEDLY_START_VM = "2101255" // 重复启动构建机,当前构建机的状态为:{0} const val ERROR_PIPELINE_VARIABLES_OUT_OF_LENGTH = "2101256" // 流水线启动参数{0}超出4000长度限制 - const val ERROR_WEBHOOK_EVENT_NOT_FOUND = "2101258" // webhook 触发记录不存在 const val BK_SUCCESSFULLY_DISTRIBUTED = "bkSuccessfullyDistributed" // 跨项目构件分发成功,共分发了{0}个文件 const val BK_SUCCESSFULLY_FAILED = "bkSuccessfullyFailed" // 跨项目构件分发失败, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt index c3e0ccd77c00..5e3316031c0d 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineTriggerEventDao.kt @@ -695,13 +695,4 @@ class PipelineTriggerEventDao { } } } - - fun getEventIdByBuildId(dslContext: DSLContext, projectId: String, buildId: String): Long? { - return with(T_PIPELINE_TRIGGER_DETAIL) { - dslContext.select(EVENT_ID) - .from(this) - .where(PROJECT_ID.eq(projectId).and(BUILD_ID.eq(buildId))) - .fetchOne()?.value1() - } - } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt index 7d02cd068403..1f981c12a487 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt @@ -452,27 +452,6 @@ class PipelineTriggerEventService @Autowired constructor( ) } - fun replayByBuild( - userId: String, - projectId: String, - pipelineId: String, - buildId: String - ) { - val eventId = pipelineTriggerEventDao.getEventIdByBuildId( - dslContext = dslContext, - projectId = projectId, - buildId = buildId - ) ?: throw ErrorCodeException( - errorCode = ProcessMessageCode.ERROR_WEBHOOK_EVENT_NOT_FOUND - ) - replayAll( - userId = userId, - projectId = projectId, - eventId = eventId, - pipelineId = pipelineId - ) - } - /** * 获取国际化构建事件描述 */ diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index da51e3acb50b..ec2298e4ab74 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -248,7 +248,6 @@ 2101254=Parameter {0} is required and cannot be empty 2101255=Start the build machine repeatedly. The current status of the build machine is: {0} 2101256=pipeline build parameter {0} value exceeds 4000 length limit -2101258=Webhook trigger event does not exist ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### # 公共变量 diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index dd353cd35876..643e85bda27f 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -248,7 +248,6 @@ 2101254=构建入参[{0}]必填,不能为空 2101255=重复启动构建机,当前构建机的状态为:{0} 2101256=流水线变量{0}值超出4000长度限制 -2101258=Webhook触发记录不存在 ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### ci.build-no=构建号,开启推荐版本号时有效 From 29eef50924e85883f38cb5eebac8ac772188f7d5 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 30 Dec 2024 10:28:44 +0800 Subject: [PATCH 04/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index f8559d2b3212..b04e19d48eda 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2711,11 +2711,24 @@ class PipelineBuildFacadeService( logger.info("build is not finished, buildId: $buildId") return } - buildRestartPipeline( + // 按原有的启动参数组装启动参数 + val startParameters = buildInfo.buildParameters?.associate { + it.key to it.value.toString() + }?.toMutableMap() ?: mutableMapOf() + val startType = StartType.toStartType(buildInfo.trigger) + // 非webhook触发 + if (startType != StartType.WEB_HOOK) return + webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> + startParameters[param.key] = param.value.toString() + } + webhookTriggerPipelineBuild( + userId = buildInfo.startUser, projectId = projectId, pipelineId = pipelineId, - buildInfo = buildInfo - ) + parameters = startParameters, + checkPermission = false, + startType = startType + )!! } private fun buildRestartPipeline( From ef956d66ae64afd5dfb1be2441139b832786aadc Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 30 Dec 2024 15:15:19 +0800 Subject: [PATCH 05/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/api/user/UserBuildResource.kt | 2 +- .../devops/process/constant/ProcessMessageCode.kt | 1 + .../devops/process/api/UserBuildResourceImpl.kt | 6 +++--- .../service/builds/PipelineBuildFacadeService.kt | 11 ++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt index b4b8ad48c75e..e63c8eb02226 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt @@ -718,5 +718,5 @@ interface UserBuildResource { @Parameter(description = "构建ID", required = true) @PathParam("buildId") buildId: String - ): Result + ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index 95d527275a86..330623b85e7f 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -362,6 +362,7 @@ object ProcessMessageCode { const val ERROR_PIPELINE_BUILD_START_PARAM_NO_EMPTY = "2101254" // 构建启动参数如果必填,不能为空 const val ERROR_REPEATEDLY_START_VM = "2101255" // 重复启动构建机,当前构建机的状态为:{0} const val ERROR_PIPELINE_VARIABLES_OUT_OF_LENGTH = "2101256" // 流水线启动参数{0}超出4000长度限制 + const val ERROR_NOT_FOUND_TRIGGER_EVENT = "2101260" // 触发事件不存在,回放失败 const val BK_SUCCESSFULLY_DISTRIBUTED = "bkSuccessfullyDistributed" // 跨项目构件分发成功,共分发了{0}个文件 const val BK_SUCCESSFULLY_FAILED = "bkSuccessfullyFailed" // 跨项目构件分发失败, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index b6e24e2b3b0a..062f0c6346dd 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -640,14 +640,14 @@ class UserBuildResourceImpl @Autowired constructor( projectId: String, pipelineId: String, buildId: String - ): Result { - pipelineBuildFacadeService.replayBuild( + ): Result { + val buildId = pipelineBuildFacadeService.replayBuild( projectId = projectId, pipelineId = pipelineId, buildId = buildId, userId = userId ) - return Result(true) + return Result(buildId) } private fun checkParam(userId: String, projectId: String, pipelineId: String) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index b04e19d48eda..5446064db9ca 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2688,7 +2688,7 @@ class PipelineBuildFacadeService( pipelineId: String, buildId: String, userId: String - ) { + ) :BuildId { pipelinePermissionService.validPipelinePermission( userId = userId, projectId = projectId, @@ -2706,18 +2706,15 @@ class PipelineBuildFacadeService( ) ) val buildInfo = checkPipelineInfo(projectId, pipelineId, buildId) - // 目标构建已经结束,直接按原有启动参数新发起一次构建,此次构建会遵循流水线配置的串行阈值 - if (!buildInfo.status.isFinish()) { - logger.info("build is not finished, buildId: $buildId") - return - } // 按原有的启动参数组装启动参数 val startParameters = buildInfo.buildParameters?.associate { it.key to it.value.toString() }?.toMutableMap() ?: mutableMapOf() val startType = StartType.toStartType(buildInfo.trigger) // 非webhook触发 - if (startType != StartType.WEB_HOOK) return + if (startType != StartType.WEB_HOOK) throw ErrorCodeException( + errorCode = ProcessMessageCode + ) webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> startParameters[param.key] = param.value.toString() } From e30ec0e2cf082467e4301d280119e33c8f53ea26 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 30 Dec 2024 15:24:57 +0800 Subject: [PATCH 06/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/UserBuildResourceImpl.kt | 13 ++++++------ .../builds/PipelineBuildFacadeService.kt | 20 ++++++++++--------- .../i18n/process/message_en_US.properties | 2 +- .../i18n/process/message_zh_CN.properties | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index 062f0c6346dd..5f8e6907890c 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -641,13 +641,14 @@ class UserBuildResourceImpl @Autowired constructor( pipelineId: String, buildId: String ): Result { - val buildId = pipelineBuildFacadeService.replayBuild( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - userId = userId + return Result( + pipelineBuildFacadeService.replayBuild( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + userId = userId + ) ) - return Result(buildId) } private fun checkParam(userId: String, projectId: String, pipelineId: String) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 5446064db9ca..e78a17efc364 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2713,19 +2713,21 @@ class PipelineBuildFacadeService( val startType = StartType.toStartType(buildInfo.trigger) // 非webhook触发 if (startType != StartType.WEB_HOOK) throw ErrorCodeException( - errorCode = ProcessMessageCode + errorCode = ProcessMessageCode.ERROR_NOT_FOUND_TRIGGER_EVENT ) webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> startParameters[param.key] = param.value.toString() } - webhookTriggerPipelineBuild( - userId = buildInfo.startUser, - projectId = projectId, - pipelineId = pipelineId, - parameters = startParameters, - checkPermission = false, - startType = startType - )!! + return BuildId( + webhookTriggerPipelineBuild( + userId = buildInfo.startUser, + projectId = projectId, + pipelineId = pipelineId, + parameters = startParameters, + checkPermission = false, + startType = startType + )!! + ) } private fun buildRestartPipeline( diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index ec2298e4ab74..aa9f37d9ea9a 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -248,7 +248,7 @@ 2101254=Parameter {0} is required and cannot be empty 2101255=Start the build machine repeatedly. The current status of the build machine is: {0} 2101256=pipeline build parameter {0} value exceeds 4000 length limit - +2101260=Replay failed, trigger event does not exist ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### # 公共变量 ci.build-no=Build number. Only available when the recommended version number is enabled. diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index 643e85bda27f..495c5ee3ea7b 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -248,6 +248,7 @@ 2101254=构建入参[{0}]必填,不能为空 2101255=重复启动构建机,当前构建机的状态为:{0} 2101256=流水线变量{0}值超出4000长度限制 +2101260=回放失败,触发事件不存在 ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### ci.build-no=构建号,开启推荐版本号时有效 From 3c5e0a0a277c6ffddd921e3fe968393c9a0665f8 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 30 Dec 2024 15:49:02 +0800 Subject: [PATCH 07/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/service/builds/PipelineBuildFacadeService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index e78a17efc364..d8b62c888532 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2688,7 +2688,7 @@ class PipelineBuildFacadeService( pipelineId: String, buildId: String, userId: String - ) :BuildId { + ): BuildId { pipelinePermissionService.validPipelinePermission( userId = userId, projectId = projectId, From dc12f64f45931b7d7a66e6a2a86e7bedf5c9fe91 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 2 Jan 2025 17:08:01 +0800 Subject: [PATCH 08/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildEventReplayService.kt | 22 ++++++++++++ .../builds/PipelineBuildFacadeService.kt | 35 ++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt new file mode 100644 index 000000000000..4f79d94be74e --- /dev/null +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt @@ -0,0 +1,22 @@ +package com.tencent.devops.process.service.builds + +import com.tencent.devops.common.webhook.pojo.code.WebHookParams +import com.tencent.devops.common.webhook.pojo.code.git.GitMergeRequestEvent +import com.tencent.devops.repository.pojo.Repository +import org.springframework.stereotype.Service + +@Service +class PipelineBuildEventReplayService { + + fun matchMrEvent( + event: GitMergeRequestEvent, + projectId: String, + pipelineId: String, + repository: Repository, + webHookParams: WebHookParams + ) { + + } + + +} \ No newline at end of file diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index d8b62c888532..27b4c1562f02 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2711,12 +2711,37 @@ class PipelineBuildFacadeService( it.key to it.value.toString() }?.toMutableMap() ?: mutableMapOf() val startType = StartType.toStartType(buildInfo.trigger) - // 非webhook触发 - if (startType != StartType.WEB_HOOK) throw ErrorCodeException( - errorCode = ProcessMessageCode.ERROR_NOT_FOUND_TRIGGER_EVENT + val readyToBuildPipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId) + ?: throw ErrorCodeException(errorCode = ProcessMessageCode.ERROR_PIPELINE_NOT_EXISTS) + if (readyToBuildPipelineInfo.locked == true) { + throw ErrorCodeException(errorCode = ProcessMessageCode.ERROR_PIPELINE_LOCK) + } + if (readyToBuildPipelineInfo.latestVersionStatus?.isNotReleased() == true) throw ErrorCodeException( + errorCode = ProcessMessageCode.ERROR_NO_RELEASE_PIPELINE_VERSION ) - webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> - startParameters[param.key] = param.value.toString() + val resource = getPipelineResourceVersion(projectId, pipelineId, readyToBuildPipelineInfo.version) + val model = resource.model + val triggerContainer = model.getTriggerContainer() + val triggerElements = when (startType) { + StartType.WEB_HOOK -> { + // webhook触发 + webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> + startParameters[param.key] = param.value.toString() + } + triggerContainer.elements.filter { it.id == startParameters[PIPELINE_START_TASK_ID] } + } + + StartType.MANUAL, StartType.SERVICE -> { + triggerContainer.elements.filterIsInstance() + } + + StartType.REMOTE -> { + triggerContainer.elements.filterIsInstance() + } + + else -> { + null + } } return BuildId( webhookTriggerPipelineBuild( From 0cf8808eb6b13e47987d3f809a6394345484c5a1 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Tue, 7 Jan 2025 17:12:25 +0800 Subject: [PATCH 09/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/user/UserBuildResource.kt | 5 ++- .../process/constant/ProcessMessageCode.kt | 1 + .../process/api/UserBuildResourceImpl.kt | 6 ++- .../builds/PipelineBuildFacadeService.kt | 44 +++++++++++++------ .../i18n/process/message_en_US.properties | 1 + .../i18n/process/message_zh_CN.properties | 2 +- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt index e63c8eb02226..72f94ec69a3b 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt @@ -717,6 +717,9 @@ interface UserBuildResource { pipelineId: String, @Parameter(description = "构建ID", required = true) @PathParam("buildId") - buildId: String + buildId: String, + @Parameter(description = "强制触发", required = false) + @QueryParam("forceTrigger") + forceTrigger: Boolean? = false ): Result } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index 330623b85e7f..c6c0ed4e7bad 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -363,6 +363,7 @@ object ProcessMessageCode { const val ERROR_REPEATEDLY_START_VM = "2101255" // 重复启动构建机,当前构建机的状态为:{0} const val ERROR_PIPELINE_VARIABLES_OUT_OF_LENGTH = "2101256" // 流水线启动参数{0}超出4000长度限制 const val ERROR_NOT_FOUND_TRIGGER_EVENT = "2101260" // 触发事件不存在,回放失败 + const val ERROR_TRIGGER_CONDITION_NOT_MATCH = "2101261" // 触发条件不匹配 const val BK_SUCCESSFULLY_DISTRIBUTED = "bkSuccessfullyDistributed" // 跨项目构件分发成功,共分发了{0}个文件 const val BK_SUCCESSFULLY_FAILED = "bkSuccessfullyFailed" // 跨项目构件分发失败, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index 5f8e6907890c..12d8b5118843 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -639,14 +639,16 @@ class UserBuildResourceImpl @Autowired constructor( userId: String, projectId: String, pipelineId: String, - buildId: String + buildId: String, + forceTrigger: Boolean? ): Result { return Result( pipelineBuildFacadeService.replayBuild( projectId = projectId, pipelineId = pipelineId, buildId = buildId, - userId = userId + userId = userId, + forceTrigger = forceTrigger ?: false ) ) } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 27b4c1562f02..cf8298ebe028 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -88,6 +88,7 @@ import com.tencent.devops.process.engine.control.lock.PipelineRefreshBuildLock import com.tencent.devops.process.engine.interceptor.InterceptData import com.tencent.devops.process.engine.interceptor.PipelineInterceptorChain import com.tencent.devops.process.engine.pojo.BuildInfo +import com.tencent.devops.process.engine.pojo.PipelineInfo import com.tencent.devops.process.engine.pojo.event.PipelineBuildContainerEvent import com.tencent.devops.process.engine.service.PipelineBuildDetailService import com.tencent.devops.process.engine.service.PipelineBuildQualityService @@ -834,7 +835,9 @@ class PipelineBuildFacadeService( startType: StartType = StartType.WEB_HOOK, startValues: Map? = null, userParameters: List? = null, - triggerReviewers: List? = null + triggerReviewers: List? = null, + pipelineResource: PipelineResourceVersion? = null, + pipelineInfo: PipelineInfo? = null, ): String? { if (checkPermission) { @@ -849,8 +852,10 @@ class PipelineBuildFacadeService( ) ) } - val readyToBuildPipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId) - ?: return null + val readyToBuildPipelineInfo = pipelineInfo ?: pipelineRepositoryService.getPipelineInfo( + projectId = projectId, + pipelineId = pipelineId + ) ?: return null if (readyToBuildPipelineInfo.locked == true) { throw ErrorCodeException(errorCode = ProcessMessageCode.ERROR_PIPELINE_LOCK) } @@ -859,8 +864,11 @@ class PipelineBuildFacadeService( ) val startEpoch = System.currentTimeMillis() try { - - val resource = getPipelineResourceVersion(projectId, pipelineId, readyToBuildPipelineInfo.version) + val resource = pipelineResource?:getPipelineResourceVersion( + projectId = projectId, + pipelineId = pipelineId, + version = readyToBuildPipelineInfo.version + ) val model = resource.model /** @@ -2687,7 +2695,8 @@ class PipelineBuildFacadeService( projectId: String, pipelineId: String, buildId: String, - userId: String + userId: String, + forceTrigger: Boolean ): BuildId { pipelinePermissionService.validPipelinePermission( userId = userId, @@ -2711,18 +2720,19 @@ class PipelineBuildFacadeService( it.key to it.value.toString() }?.toMutableMap() ?: mutableMapOf() val startType = StartType.toStartType(buildInfo.trigger) - val readyToBuildPipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId) + val pipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId) ?: throw ErrorCodeException(errorCode = ProcessMessageCode.ERROR_PIPELINE_NOT_EXISTS) - if (readyToBuildPipelineInfo.locked == true) { + if (pipelineInfo.locked == true) { throw ErrorCodeException(errorCode = ProcessMessageCode.ERROR_PIPELINE_LOCK) } - if (readyToBuildPipelineInfo.latestVersionStatus?.isNotReleased() == true) throw ErrorCodeException( + if (pipelineInfo.latestVersionStatus?.isNotReleased() == true) throw ErrorCodeException( errorCode = ProcessMessageCode.ERROR_NO_RELEASE_PIPELINE_VERSION ) - val resource = getPipelineResourceVersion(projectId, pipelineId, readyToBuildPipelineInfo.version) - val model = resource.model + val pipelineResourceVersion = getPipelineResourceVersion(projectId, pipelineId, pipelineInfo.version) + val model = pipelineResourceVersion.model val triggerContainer = model.getTriggerContainer() - val triggerElements = when (startType) { + // 检查触发器是否存在 + val checkTriggerResult = forceTrigger || when (startType) { StartType.WEB_HOOK -> { // webhook触发 webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> @@ -2742,6 +2752,12 @@ class PipelineBuildFacadeService( else -> { null } + }.isNullOrEmpty() + if (checkTriggerResult) { + throw ErrorCodeException( + errorCode = ProcessMessageCode.ERROR_TRIGGER_CONDITION_NOT_MATCH, + params = arrayOf(pipelineResourceVersion.versionName ?: "") + ) } return BuildId( webhookTriggerPipelineBuild( @@ -2750,7 +2766,9 @@ class PipelineBuildFacadeService( pipelineId = pipelineId, parameters = startParameters, checkPermission = false, - startType = startType + startType = startType, + pipelineInfo = pipelineInfo, + pipelineResource = pipelineResourceVersion )!! ) } diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index aa9f37d9ea9a..ea40195fac71 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -249,6 +249,7 @@ 2101255=Start the build machine repeatedly. The current status of the build machine is: {0} 2101256=pipeline build parameter {0} value exceeds 4000 length limit 2101260=Replay failed, trigger event does not exist +2101261=Same trigger parameters, no longer meet the trigger conditions of the current pipeline latest version {0}. Continuing to run may produce errors. Confirm to continue? ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### # 公共变量 ci.build-no=Build number. Only available when the recommended version number is enabled. diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index 495c5ee3ea7b..f5a31d7d58e2 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -249,7 +249,7 @@ 2101255=重复启动构建机,当前构建机的状态为:{0} 2101256=流水线变量{0}值超出4000长度限制 2101260=回放失败,触发事件不存在 - +2101261=同样的触发参数, 已不满足当前流水线最新版本 {0} 的触发条件, 继续运行可能会产生错误, 确认继续吗 ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### ci.build-no=构建号,开启推荐版本号时有效 ci.build_num=当前构建的唯一标示ID,从1开始自增 From b6ea3b1c8deebeb0567d747bd12dc3cdbc2fc9fb Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 10:06:03 +0800 Subject: [PATCH 10/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildEventReplayService.kt | 22 ------------------- .../builds/PipelineBuildFacadeService.kt | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt deleted file mode 100644 index 4f79d94be74e..000000000000 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildEventReplayService.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.tencent.devops.process.service.builds - -import com.tencent.devops.common.webhook.pojo.code.WebHookParams -import com.tencent.devops.common.webhook.pojo.code.git.GitMergeRequestEvent -import com.tencent.devops.repository.pojo.Repository -import org.springframework.stereotype.Service - -@Service -class PipelineBuildEventReplayService { - - fun matchMrEvent( - event: GitMergeRequestEvent, - projectId: String, - pipelineId: String, - repository: Repository, - webHookParams: WebHookParams - ) { - - } - - -} \ No newline at end of file diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index cf8298ebe028..8d8cb0238b47 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -864,7 +864,7 @@ class PipelineBuildFacadeService( ) val startEpoch = System.currentTimeMillis() try { - val resource = pipelineResource?:getPipelineResourceVersion( + val resource = pipelineResource ?: getPipelineResourceVersion( projectId = projectId, pipelineId = pipelineId, version = readyToBuildPipelineInfo.version From 9b5a8550efac58601329bd91a75157a86c15b68e Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 11:15:38 +0800 Subject: [PATCH 11/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 8d8cb0238b47..881455f59549 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2759,18 +2759,52 @@ class PipelineBuildFacadeService( params = arrayOf(pipelineResourceVersion.versionName ?: "") ) } - return BuildId( - webhookTriggerPipelineBuild( - userId = buildInfo.startUser, + return triggerPipeline( + userId = buildInfo.startUser, + projectId = projectId, + pipelineId = pipelineId, + startParameters = startParameters, + startType = startType, + pipelineInfo = pipelineInfo, + pipelineResourceVersion = pipelineResourceVersion + ) + } + + private fun triggerPipeline( + startType: StartType, + projectId: String, + pipelineId: String, + startParameters: Map, + pipelineInfo: PipelineInfo? = null, + pipelineResourceVersion: PipelineResourceVersion? = null, + userId: String + ) = when (startType) { + StartType.WEB_HOOK -> { + // webhook触发 + BuildId( + webhookTriggerPipelineBuild( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + parameters = startParameters, + checkPermission = false, + startType = startType, + pipelineInfo = pipelineInfo, + pipelineResource = pipelineResourceVersion + )!! + ) + } + + StartType.MANUAL, StartType.SERVICE, StartType.REMOTE, StartType.TIME_TRIGGER, StartType.PIPELINE -> { + buildManualStartup( + userId = userId, projectId = projectId, pipelineId = pipelineId, - parameters = startParameters, - checkPermission = false, - startType = startType, - pipelineInfo = pipelineInfo, - pipelineResource = pipelineResourceVersion - )!! - ) + channelCode = ChannelCode.BS, + values = startParameters, + startType = startType + ) + } } private fun buildRestartPipeline( From 6cd973502bf65391f69a7db1c378bbc9bf993b7d Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 11:43:33 +0800 Subject: [PATCH 12/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 881455f59549..d99c0603f894 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -56,11 +56,13 @@ import com.tencent.devops.common.pipeline.pojo.BuildFormProperty import com.tencent.devops.common.pipeline.pojo.BuildFormValue import com.tencent.devops.common.pipeline.pojo.BuildParameters import com.tencent.devops.common.pipeline.pojo.StageReviewRequest +import com.tencent.devops.common.pipeline.pojo.element.EmptyElement import com.tencent.devops.common.pipeline.pojo.element.agent.ManualReviewUserTaskElement import com.tencent.devops.common.pipeline.pojo.element.atom.ManualReviewParam import com.tencent.devops.common.pipeline.pojo.element.atom.ManualReviewParamType import com.tencent.devops.common.pipeline.pojo.element.trigger.ManualTriggerElement import com.tencent.devops.common.pipeline.pojo.element.trigger.RemoteTriggerElement +import com.tencent.devops.common.pipeline.pojo.element.trigger.TimerTriggerElement import com.tencent.devops.common.pipeline.utils.BuildStatusSwitcher import com.tencent.devops.common.pipeline.utils.PIPELINE_SETTING_MAX_CON_QUEUE_SIZE_MAX import com.tencent.devops.common.redis.RedisOperation @@ -2738,21 +2740,25 @@ class PipelineBuildFacadeService( webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> startParameters[param.key] = param.value.toString() } - triggerContainer.elements.filter { it.id == startParameters[PIPELINE_START_TASK_ID] } + triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] } } StartType.MANUAL, StartType.SERVICE -> { - triggerContainer.elements.filterIsInstance() + triggerContainer.elements.find { it is ManualTriggerElement } } StartType.REMOTE -> { - triggerContainer.elements.filterIsInstance() + triggerContainer.elements.find { it is RemoteTriggerElement } } - else -> { - null + StartType.TIME_TRIGGER -> { + triggerContainer.elements.find { it is TimerTriggerElement } + } + + StartType.PIPELINE -> { + EmptyElement() } - }.isNullOrEmpty() + } == null if (checkTriggerResult) { throw ErrorCodeException( errorCode = ProcessMessageCode.ERROR_TRIGGER_CONDITION_NOT_MATCH, From fe9ed354e6ebc1f506146e0da010e1b3fa698bc0 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 15:00:56 +0800 Subject: [PATCH 13/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SubPipelineStartUpService.kt | 2 +- .../builds/PipelineBuildFacadeService.kt | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt index 677b20f0b18d..27f71a2b044c 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt @@ -97,7 +97,7 @@ class SubPipelineStartUpService @Autowired constructor( companion object { private val logger = LoggerFactory.getLogger(SubPipelineStartUpService::class.java) - private const val SYNC_RUN_MODE = "syn" + const val SYNC_RUN_MODE = "syn" } /** diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index d99c0603f894..5cefd3e9d608 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -126,8 +126,8 @@ import com.tencent.devops.process.pojo.pipeline.PipelineResourceVersion import com.tencent.devops.process.service.BuildVariableService import com.tencent.devops.process.service.ParamFacadeService import com.tencent.devops.process.service.PipelineTaskPauseService +import com.tencent.devops.process.service.SubPipelineStartUpService import com.tencent.devops.process.service.pipeline.PipelineBuildService -import com.tencent.devops.process.service.template.TemplateFacadeService import com.tencent.devops.process.strategy.context.UserPipelinePermissionCheckContext import com.tencent.devops.process.strategy.factory.UserPipelinePermissionCheckStrategyFactory import com.tencent.devops.process.util.TaskUtils @@ -138,6 +138,12 @@ import com.tencent.devops.process.utils.PIPELINE_RETRY_BUILD_ID import com.tencent.devops.process.utils.PIPELINE_RETRY_COUNT import com.tencent.devops.process.utils.PIPELINE_RETRY_START_TASK_ID import com.tencent.devops.process.utils.PIPELINE_SKIP_FAILED_TASK +import com.tencent.devops.process.utils.PIPELINE_START_PARENT_BUILD_ID +import com.tencent.devops.process.utils.PIPELINE_START_PARENT_BUILD_TASK_ID +import com.tencent.devops.process.utils.PIPELINE_START_PARENT_EXECUTE_COUNT +import com.tencent.devops.process.utils.PIPELINE_START_PARENT_PIPELINE_ID +import com.tencent.devops.process.utils.PIPELINE_START_PARENT_PROJECT_ID +import com.tencent.devops.process.utils.PIPELINE_START_SUB_RUN_MODE import com.tencent.devops.process.utils.PIPELINE_START_TASK_ID import com.tencent.devops.process.utils.PipelineVarUtil.recommendVersionKey import com.tencent.devops.process.yaml.PipelineYamlFacadeService @@ -180,7 +186,7 @@ class PipelineBuildFacadeService( private val pipelineRetryFacadeService: PipelineRetryFacadeService, private val webhookBuildParameterService: WebhookBuildParameterService, private val pipelineYamlFacadeService: PipelineYamlFacadeService, - private val templateFacadeService: TemplateFacadeService + private val subPipelineStartUpService: SubPipelineStartUpService ) { @Value("\${pipeline.build.cancel.intervalLimitTime:60}") @@ -2801,7 +2807,7 @@ class PipelineBuildFacadeService( ) } - StartType.MANUAL, StartType.SERVICE, StartType.REMOTE, StartType.TIME_TRIGGER, StartType.PIPELINE -> { + StartType.MANUAL, StartType.SERVICE, StartType.REMOTE, StartType.TIME_TRIGGER -> { buildManualStartup( userId = userId, projectId = projectId, @@ -2811,6 +2817,24 @@ class PipelineBuildFacadeService( startType = startType ) } + + StartType.PIPELINE -> { + BuildId( + subPipelineStartUpService.callPipelineStartup( + projectId = startParameters[PIPELINE_START_PARENT_PROJECT_ID]!!, + parentPipelineId = startParameters[PIPELINE_START_PARENT_PIPELINE_ID]!!, + buildId = startParameters[PIPELINE_START_PARENT_BUILD_ID]!!, + callProjectId = projectId, + callPipelineId = pipelineId, + atomCode = "SubPipelineExec", + taskId = startParameters[PIPELINE_START_PARENT_BUILD_TASK_ID]!!, + channelCode = ChannelCode.BS, + values = startParameters, + runMode = startParameters[PIPELINE_START_SUB_RUN_MODE] ?: SubPipelineStartUpService.SYNC_RUN_MODE, + executeCount = startParameters[PIPELINE_START_PARENT_EXECUTE_COUNT]?.toInt() + ).data.id + ) + } } private fun buildRestartPipeline( From 8c2654294274a5290be6b3b69df60d5b62536b8d Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 15:04:37 +0800 Subject: [PATCH 14/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/service/builds/PipelineBuildFacadeService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 5cefd3e9d608..24e6c306f0a2 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2832,7 +2832,7 @@ class PipelineBuildFacadeService( values = startParameters, runMode = startParameters[PIPELINE_START_SUB_RUN_MODE] ?: SubPipelineStartUpService.SYNC_RUN_MODE, executeCount = startParameters[PIPELINE_START_PARENT_EXECUTE_COUNT]?.toInt() - ).data.id + ).data!!.id ) } } From 764c2b1ad9436d756be0ca67e4a17d2d4e85eec9 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 15:22:15 +0800 Subject: [PATCH 15/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/service/builds/PipelineBuildFacadeService.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 24e6c306f0a2..f1c240617621 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -150,6 +150,7 @@ import com.tencent.devops.process.yaml.PipelineYamlFacadeService import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Lazy import org.springframework.stereotype.Service import java.util.concurrent.TimeUnit import javax.ws.rs.core.Response @@ -186,6 +187,7 @@ class PipelineBuildFacadeService( private val pipelineRetryFacadeService: PipelineRetryFacadeService, private val webhookBuildParameterService: WebhookBuildParameterService, private val pipelineYamlFacadeService: PipelineYamlFacadeService, + @Lazy private val subPipelineStartUpService: SubPipelineStartUpService ) { From 6f0b7fa7092c01893428872e48cee04a1632ccaf Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 15:52:30 +0800 Subject: [PATCH 16/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/service/builds/PipelineBuildFacadeService.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index f1c240617621..68575a346563 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2764,6 +2764,11 @@ class PipelineBuildFacadeService( } StartType.PIPELINE -> { + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId + ).forEach { (key, value) -> startParameters[key] = value } EmptyElement() } } == null From dd3aad8d5c4100f5e89fe1cb38761127a7a2880d Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 16:58:58 +0800 Subject: [PATCH 17/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 68575a346563..05e31760b6e2 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -131,6 +131,9 @@ import com.tencent.devops.process.service.pipeline.PipelineBuildService import com.tencent.devops.process.strategy.context.UserPipelinePermissionCheckContext import com.tencent.devops.process.strategy.factory.UserPipelinePermissionCheckStrategyFactory import com.tencent.devops.process.util.TaskUtils +import com.tencent.devops.process.utils.BK_CI_MATERIAL_ID +import com.tencent.devops.process.utils.BK_CI_MATERIAL_NAME +import com.tencent.devops.process.utils.BK_CI_MATERIAL_URL import com.tencent.devops.process.utils.PIPELINE_BUILD_MSG import com.tencent.devops.process.utils.PIPELINE_NAME import com.tencent.devops.process.utils.PIPELINE_RETRY_ALL_FAILED_CONTAINER @@ -2752,10 +2755,28 @@ class PipelineBuildFacadeService( } StartType.MANUAL, StartType.SERVICE -> { + // 自定义触发源材料信息 + startParameters.putAll( + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + ) + ) triggerContainer.elements.find { it is ManualTriggerElement } } StartType.REMOTE -> { + startParameters.putAll( + // 自定义触发源材料参数 + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + ) + ) triggerContainer.elements.find { it is RemoteTriggerElement } } @@ -2764,6 +2785,22 @@ class PipelineBuildFacadeService( } StartType.PIPELINE -> { + // 父子流水线核心参数 + startParameters.putAll( + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf( + PIPELINE_START_PARENT_PROJECT_ID, + PIPELINE_START_PARENT_PIPELINE_ID, + PIPELINE_START_PARENT_BUILD_ID, + PIPELINE_START_PARENT_BUILD_TASK_ID, + PIPELINE_START_SUB_RUN_MODE, + PIPELINE_START_PARENT_EXECUTE_COUNT + ) + ) + ) buildVariableService.getAllVariable( projectId = projectId, pipelineId = pipelineId, @@ -2814,7 +2851,7 @@ class PipelineBuildFacadeService( ) } - StartType.MANUAL, StartType.SERVICE, StartType.REMOTE, StartType.TIME_TRIGGER -> { + StartType.MANUAL, StartType.SERVICE, StartType.REMOTE -> { buildManualStartup( userId = userId, projectId = projectId, @@ -2825,6 +2862,18 @@ class PipelineBuildFacadeService( ) } + StartType.TIME_TRIGGER -> { + BuildId( + timerTriggerPipelineBuild( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + parameters = startParameters, + checkPermission = false + ) ?: "" + ) + } + StartType.PIPELINE -> { BuildId( subPipelineStartUpService.callPipelineStartup( From 122195be7359a545e122348d1e77645fa3244ea8 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Jan 2025 17:57:56 +0800 Subject: [PATCH 18/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 05e31760b6e2..b84df4e0743e 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2747,41 +2747,47 @@ class PipelineBuildFacadeService( // 检查触发器是否存在 val checkTriggerResult = forceTrigger || when (startType) { StartType.WEB_HOOK -> { - // webhook触发 - webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> - startParameters[param.key] = param.value.toString() + triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] }?.let { + // webhook触发 + webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> + startParameters[param.key] = param.value.toString() + } + it } - triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] } } StartType.MANUAL, StartType.SERVICE -> { - // 自定义触发源材料信息 - startParameters.putAll( - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + triggerContainer.elements.find { it is ManualTriggerElement }?.let { + startParameters.putAll( + // 自定义触发源材料参数 + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + ) ) - ) - triggerContainer.elements.find { it is ManualTriggerElement } + it + } } StartType.REMOTE -> { - startParameters.putAll( - // 自定义触发源材料参数 - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + triggerContainer.elements.find { it is RemoteTriggerElement }?.let { + startParameters.putAll( + // 自定义触发源材料参数 + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + ) ) - ) - triggerContainer.elements.find { it is RemoteTriggerElement } + it + } } StartType.TIME_TRIGGER -> { - triggerContainer.elements.find { it is TimerTriggerElement } + triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] } } StartType.PIPELINE -> { From 41430744f67d20544fa9980fbd268c80d6ce1330 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 10:03:16 +0800 Subject: [PATCH 19/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/service/builds/PipelineBuildFacadeService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index b84df4e0743e..01eeb4b5fc9d 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -62,7 +62,6 @@ import com.tencent.devops.common.pipeline.pojo.element.atom.ManualReviewParam import com.tencent.devops.common.pipeline.pojo.element.atom.ManualReviewParamType import com.tencent.devops.common.pipeline.pojo.element.trigger.ManualTriggerElement import com.tencent.devops.common.pipeline.pojo.element.trigger.RemoteTriggerElement -import com.tencent.devops.common.pipeline.pojo.element.trigger.TimerTriggerElement import com.tencent.devops.common.pipeline.utils.BuildStatusSwitcher import com.tencent.devops.common.pipeline.utils.PIPELINE_SETTING_MAX_CON_QUEUE_SIZE_MAX import com.tencent.devops.common.redis.RedisOperation From 5887ac576eaee0f9c1bc569538939b6d762a3acf Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 10:12:44 +0800 Subject: [PATCH 20/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/constant/ProcessMessageCode.kt | 3 +-- support-files/i18n/process/message_en_US.properties | 3 +-- support-files/i18n/process/message_zh_CN.properties | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index c6c0ed4e7bad..cf879c365c5c 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -362,8 +362,7 @@ object ProcessMessageCode { const val ERROR_PIPELINE_BUILD_START_PARAM_NO_EMPTY = "2101254" // 构建启动参数如果必填,不能为空 const val ERROR_REPEATEDLY_START_VM = "2101255" // 重复启动构建机,当前构建机的状态为:{0} const val ERROR_PIPELINE_VARIABLES_OUT_OF_LENGTH = "2101256" // 流水线启动参数{0}超出4000长度限制 - const val ERROR_NOT_FOUND_TRIGGER_EVENT = "2101260" // 触发事件不存在,回放失败 - const val ERROR_TRIGGER_CONDITION_NOT_MATCH = "2101261" // 触发条件不匹配 + const val ERROR_TRIGGER_CONDITION_NOT_MATCH = "2101260" // 触发条件不匹配 const val BK_SUCCESSFULLY_DISTRIBUTED = "bkSuccessfullyDistributed" // 跨项目构件分发成功,共分发了{0}个文件 const val BK_SUCCESSFULLY_FAILED = "bkSuccessfullyFailed" // 跨项目构件分发失败, diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index ea40195fac71..23236a6e6353 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -248,8 +248,7 @@ 2101254=Parameter {0} is required and cannot be empty 2101255=Start the build machine repeatedly. The current status of the build machine is: {0} 2101256=pipeline build parameter {0} value exceeds 4000 length limit -2101260=Replay failed, trigger event does not exist -2101261=Same trigger parameters, no longer meet the trigger conditions of the current pipeline latest version {0}. Continuing to run may produce errors. Confirm to continue? +2101260=Same trigger parameters, no longer meet the trigger conditions of the current pipeline latest version {0}. Continuing to run may produce errors. Confirm to continue? ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### # 公共变量 ci.build-no=Build number. Only available when the recommended version number is enabled. diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index f5a31d7d58e2..5343caa01538 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -248,8 +248,7 @@ 2101254=构建入参[{0}]必填,不能为空 2101255=重复启动构建机,当前构建机的状态为:{0} 2101256=流水线变量{0}值超出4000长度限制 -2101260=回放失败,触发事件不存在 -2101261=同样的触发参数, 已不满足当前流水线最新版本 {0} 的触发条件, 继续运行可能会产生错误, 确认继续吗 +2101260=同样的触发参数, 已不满足当前流水线最新版本 {0} 的触发条件, 继续运行可能会产生错误, 确认继续吗 ATOM_POST_EXECUTE_TIP=###Tip:this is the post-action hooked by [step{0}]{1}### ci.build-no=构建号,开启推荐版本号时有效 ci.build_num=当前构建的唯一标示ID,从1开始自增 From 0a32036dad74cb58ff6181afaaefb1d48a0ba6bf Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 13 Jan 2025 15:36:22 +0800 Subject: [PATCH 21/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/service/builds/PipelineBuildFacadeService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 01eeb4b5fc9d..809008c4c140 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2813,8 +2813,8 @@ class PipelineBuildFacadeService( ).forEach { (key, value) -> startParameters[key] = value } EmptyElement() } - } == null - if (checkTriggerResult) { + } != null + if (!checkTriggerResult) { throw ErrorCodeException( errorCode = ProcessMessageCode.ERROR_TRIGGER_CONDITION_NOT_MATCH, params = arrayOf(pipelineResourceVersion.versionName ?: "") From 5f117890a2e3f5def59b17df4171a8e6f86eab7e Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 13 Jan 2025 15:57:32 +0800 Subject: [PATCH 22/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builds/PipelineBuildFacadeService.kt | 88 ++++++++----------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 809008c4c140..326f7f090a34 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2746,43 +2746,15 @@ class PipelineBuildFacadeService( // 检查触发器是否存在 val checkTriggerResult = forceTrigger || when (startType) { StartType.WEB_HOOK -> { - triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] }?.let { - // webhook触发 - webhookBuildParameterService.getBuildParameters(buildId = buildInfo.buildId)?.forEach { param -> - startParameters[param.key] = param.value.toString() - } - it - } + triggerContainer.elements.find { it.id == startParameters[PIPELINE_START_TASK_ID] } } StartType.MANUAL, StartType.SERVICE -> { - triggerContainer.elements.find { it is ManualTriggerElement }?.let { - startParameters.putAll( - // 自定义触发源材料参数 - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) - ) - ) - it - } + triggerContainer.elements.find { it is ManualTriggerElement } } StartType.REMOTE -> { - triggerContainer.elements.find { it is RemoteTriggerElement }?.let { - startParameters.putAll( - // 自定义触发源材料参数 - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) - ) - ) - it - } + triggerContainer.elements.find { it is RemoteTriggerElement } } StartType.TIME_TRIGGER -> { @@ -2790,27 +2762,6 @@ class PipelineBuildFacadeService( } StartType.PIPELINE -> { - // 父子流水线核心参数 - startParameters.putAll( - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId, - keys = setOf( - PIPELINE_START_PARENT_PROJECT_ID, - PIPELINE_START_PARENT_PIPELINE_ID, - PIPELINE_START_PARENT_BUILD_ID, - PIPELINE_START_PARENT_BUILD_TASK_ID, - PIPELINE_START_SUB_RUN_MODE, - PIPELINE_START_PARENT_EXECUTE_COUNT - ) - ) - ) - buildVariableService.getAllVariable( - projectId = projectId, - pipelineId = pipelineId, - buildId = buildId - ).forEach { (key, value) -> startParameters[key] = value } EmptyElement() } } != null @@ -2824,6 +2775,7 @@ class PipelineBuildFacadeService( userId = buildInfo.startUser, projectId = projectId, pipelineId = pipelineId, + buildId = buildId, startParameters = startParameters, startType = startType, pipelineInfo = pipelineInfo, @@ -2835,12 +2787,17 @@ class PipelineBuildFacadeService( startType: StartType, projectId: String, pipelineId: String, - startParameters: Map, + buildId: String, + startParameters: MutableMap, pipelineInfo: PipelineInfo? = null, pipelineResourceVersion: PipelineResourceVersion? = null, userId: String ) = when (startType) { StartType.WEB_HOOK -> { + // webhook触发 + webhookBuildParameterService.getBuildParameters(buildId = buildId)?.forEach { param -> + startParameters[param.key] = param.value.toString() + } // webhook触发 BuildId( webhookTriggerPipelineBuild( @@ -2857,6 +2814,15 @@ class PipelineBuildFacadeService( } StartType.MANUAL, StartType.SERVICE, StartType.REMOTE -> { + startParameters.putAll( + // 自定义触发源材料参数 + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf(BK_CI_MATERIAL_ID, BK_CI_MATERIAL_NAME, BK_CI_MATERIAL_URL) + ) + ) buildManualStartup( userId = userId, projectId = projectId, @@ -2880,6 +2846,22 @@ class PipelineBuildFacadeService( } StartType.PIPELINE -> { + // 父子流水线核心参数 + startParameters.putAll( + buildVariableService.getAllVariable( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + keys = setOf( + PIPELINE_START_PARENT_PROJECT_ID, + PIPELINE_START_PARENT_PIPELINE_ID, + PIPELINE_START_PARENT_BUILD_ID, + PIPELINE_START_PARENT_BUILD_TASK_ID, + PIPELINE_START_SUB_RUN_MODE, + PIPELINE_START_PARENT_EXECUTE_COUNT + ) + ) + ) BuildId( subPipelineStartUpService.callPipelineStartup( projectId = startParameters[PIPELINE_START_PARENT_PROJECT_ID]!!, From fa170b23454df836353cd797fda93b11a6834538 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 13 Jan 2025 16:52:50 +0800 Subject: [PATCH 23/23] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/service/builds/PipelineBuildFacadeService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 326f7f090a34..794129039659 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -2727,8 +2727,10 @@ class PipelineBuildFacadeService( ) ) val buildInfo = checkPipelineInfo(projectId, pipelineId, buildId) - // 按原有的启动参数组装启动参数 - val startParameters = buildInfo.buildParameters?.associate { + // 按原有的启动参数组装启动参数(排除重试次数) + val startParameters = buildInfo.buildParameters?.filter { + it.key != PIPELINE_RETRY_COUNT + }?.associate { it.key to it.value.toString() }?.toMutableMap() ?: mutableMapOf() val startType = StartType.toStartType(buildInfo.trigger)