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] =?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 b4b8ad48c75..e63c8eb0222 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 95d527275a8..330623b85e7 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 b6e24e2b3b0..062f0c6346d 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 b04e19d48ed..5446064db9c 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() }