Skip to content

Commit

Permalink
Merge 'issue_4531' into 'issue_4732'
Browse files Browse the repository at this point in the history
  • Loading branch information
royalhuang committed Aug 19, 2021
2 parents ccb642e + 35aad73 commit 3e77d7e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PipelineStageService @Autowired constructor(
}
}

fun pauseStage(userId: String, buildStage: PipelineBuildStage) {
fun pauseStage(buildStage: PipelineBuildStage) {
with(buildStage) {
// TODO 暂时只处理准入逻辑,后续和checkOut保持逻辑一致
checkIn?.status = BuildStatus.REVIEWING.name
Expand Down Expand Up @@ -234,7 +234,6 @@ class PipelineStageService @Autowired constructor(
stageId = stageId, buildStatus = BuildStatus.PAUSE,
controlOption = controlOption, checkIn = checkIn, checkOut = checkOut
)

// 如果还有待审核的审核组,则直接通知并返回
if (checkIn?.groupToReview() != null) {
val variables = buildVariableService.getAllVariable(buildId)
Expand All @@ -244,42 +243,37 @@ class PipelineStageService @Autowired constructor(
pipelineName = variables[PIPELINE_NAME] ?: pipelineId,
buildNum = variables[PIPELINE_BUILD_NUM] ?: "1"
)
return true
}
val allStageStatus = stageBuildDetailService.stageStart(
buildId = buildId, stageId = stageId,
controlOption = controlOption!!,
checkIn = checkIn, checkOut = checkOut
)

dslContext.transaction { configuration ->
val context = DSL.using(configuration)
pipelineBuildStageDao.updateStatus(
dslContext = context, buildId = buildId,
stageId = stageId, buildStatus = BuildStatus.QUEUE,
controlOption = controlOption, checkIn = checkIn, checkOut = checkOut
)
pipelineBuildDao.updateStatus(
dslContext = context, buildId = buildId,
oldBuildStatus = BuildStatus.STAGE_SUCCESS, newBuildStatus = BuildStatus.RUNNING
)
pipelineBuildDao.updateBuildStageStatus(
dslContext = context, buildId = buildId, stageStatus = allStageStatus
} else {
val allStageStatus = stageBuildDetailService.stageStart(
buildId = buildId, stageId = stageId,
controlOption = controlOption!!,
checkIn = checkIn, checkOut = checkOut
)
pipelineBuildSummaryDao.updateRunningCount(
dslContext = context, pipelineId = pipelineId, buildId = buildId, runningIncrement = 1
dslContext.transaction { configuration ->
val context = DSL.using(configuration)
pipelineBuildStageDao.updateStatus(
dslContext = context, buildId = buildId, stageId = stageId, buildStatus = BuildStatus.QUEUE,
controlOption = controlOption, checkIn = checkIn, checkOut = checkOut
)
pipelineBuildDao.updateStatus(
dslContext = context, buildId = buildId,
oldBuildStatus = BuildStatus.STAGE_SUCCESS, newBuildStatus = BuildStatus.RUNNING
)
pipelineBuildDao.updateBuildStageStatus(
dslContext = context, buildId = buildId, stageStatus = allStageStatus
)
pipelineBuildSummaryDao.updateRunningCount(
dslContext = context, pipelineId = pipelineId, buildId = buildId, runningIncrement = 1
)
}
pipelineEventDispatcher.dispatch(
PipelineBuildStageEvent(
source = BS_MANUAL_START_STAGE, projectId = projectId, pipelineId = pipelineId,
userId = userId, buildId = buildId, stageId = stageId, actionType = ActionType.REFRESH
)
// #3400 点Stage启动时处于DETAIL界面,以操作人视角,没有刷历史列表的必要
)
}

pipelineEventDispatcher.dispatch(
PipelineBuildStageEvent(
source = BS_MANUAL_START_STAGE, projectId = projectId,
pipelineId = pipelineId, userId = userId,
buildId = buildId, stageId = stageId,
actionType = ActionType.REFRESH
)
// #3400 点Stage启动时处于DETAIL界面,以操作人视角,没有刷历史列表的必要
)
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class UpdateStateForStageCmdFinally(
// Stage 暂停
if (commandContext.buildStatus == BuildStatus.STAGE_SUCCESS) {
if (event.source != BS_STAGE_CANCELED_END_SOURCE) { // 不是 stage cancel,暂停
pipelineStageService.pauseStage(userId = event.userId, buildStage = stage)
pipelineStageService.pauseStage(stage)
} else {
nextOrFinish(event, stage, commandContext)
sendStageEndCallBack(stage, event)
Expand Down

0 comments on commit 3e77d7e

Please sign in to comment.