Skip to content

Commit

Permalink
feat:支持针对构建重放事件 #11232
Browse files Browse the repository at this point in the history
  • Loading branch information
hejieehe committed Dec 30, 2024
1 parent 29eef50 commit ef956d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,5 +718,5 @@ interface UserBuildResource {
@Parameter(description = "构建ID", required = true)
@PathParam("buildId")
buildId: String
): Result<Boolean>
): Result<BuildId>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" // 跨项目构件分发失败,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,14 @@ class UserBuildResourceImpl @Autowired constructor(
projectId: String,
pipelineId: String,
buildId: String
): Result<Boolean> {
pipelineBuildFacadeService.replayBuild(
): Result<BuildId> {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,7 @@ class PipelineBuildFacadeService(
pipelineId: String,
buildId: String,
userId: String
) {
) :BuildId {
pipelinePermissionService.validPipelinePermission(
userId = userId,
projectId = projectId,
Expand All @@ -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()
}
Expand Down

0 comments on commit ef956d6

Please sign in to comment.