fix: 清理发布步骤终态提示
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* 编排发布单从 Gitea 校验、Jenkins 构建、健康检查到通知归档的状态推进。
|
||||
* Jenkins 触发与轮询可能跨进程完成,终态写入时必须清理运行态提示。
|
||||
*/
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { AuditService } from '../audit/audit.service';
|
||||
import { AppError } from '../common/errors/app-error';
|
||||
@@ -53,7 +57,11 @@ export class DeployExecutionService {
|
||||
|
||||
try {
|
||||
currentStep = 'gitea-check';
|
||||
currentRun = await this.completeStep(currentRun.id, currentStep, 'success');
|
||||
currentRun = await this.completeStep(
|
||||
currentRun.id,
|
||||
currentStep,
|
||||
'success',
|
||||
);
|
||||
|
||||
currentStep = 'jenkins-build';
|
||||
const jenkinsResult = await this.advanceJenkinsBuild(currentRun, project);
|
||||
@@ -65,13 +73,21 @@ export class DeployExecutionService {
|
||||
}
|
||||
|
||||
currentStep = 'health-check';
|
||||
currentRun = await this.completeStep(currentRun.id, currentStep, 'success');
|
||||
currentRun = await this.completeStep(
|
||||
currentRun.id,
|
||||
currentStep,
|
||||
'success',
|
||||
);
|
||||
|
||||
currentStep = 'notify-wecom';
|
||||
currentRun = await this.advanceNotification(currentRun, 'succeeded');
|
||||
|
||||
currentStep = 'finish-release';
|
||||
currentRun = await this.completeStep(currentRun.id, currentStep, 'success');
|
||||
currentRun = await this.completeStep(
|
||||
currentRun.id,
|
||||
currentStep,
|
||||
'success',
|
||||
);
|
||||
currentRun = this.requireRun(
|
||||
currentRun.id,
|
||||
await this.deployRunRepository.updateRun(currentRun.id, {
|
||||
@@ -102,6 +118,7 @@ export class DeployExecutionService {
|
||||
currentStep,
|
||||
{
|
||||
status: 'failed',
|
||||
message: undefined,
|
||||
errorSummary: failureSummary,
|
||||
},
|
||||
)) ?? currentRun;
|
||||
@@ -205,7 +222,10 @@ export class DeployExecutionService {
|
||||
currentRun = this.requireRun(
|
||||
currentRun.id,
|
||||
await this.deployRunRepository.updateRun(currentRun.id, {
|
||||
status: buildStatus.building || !buildStatus.result ? 'running' : currentRun.status,
|
||||
status:
|
||||
buildStatus.building || !buildStatus.result
|
||||
? 'running'
|
||||
: currentRun.status,
|
||||
jenkinsBuildNumber: buildStatus.buildNumber,
|
||||
jenkinsBuildUrl: buildStatus.url,
|
||||
}),
|
||||
@@ -242,7 +262,11 @@ export class DeployExecutionService {
|
||||
const reason =
|
||||
health.message ??
|
||||
'Jenkins is not configured; simulated build completed.';
|
||||
const currentRun = await this.completeStep(run.id, 'jenkins-build', 'success');
|
||||
const currentRun = await this.completeStep(
|
||||
run.id,
|
||||
'jenkins-build',
|
||||
'success',
|
||||
);
|
||||
|
||||
this.auditService.record({
|
||||
action: 'JENKINS_DRY_RUN_COMPLETED',
|
||||
@@ -346,10 +370,22 @@ export class DeployExecutionService {
|
||||
private async completeSuccessfulJenkinsRun(
|
||||
run: DeployRunSummary,
|
||||
): Promise<DeployRunSummary> {
|
||||
let currentRun = await this.completeStep(run.id, 'jenkins-build', 'success');
|
||||
currentRun = await this.completeStep(currentRun.id, 'health-check', 'success');
|
||||
let currentRun = await this.completeStep(
|
||||
run.id,
|
||||
'jenkins-build',
|
||||
'success',
|
||||
);
|
||||
currentRun = await this.completeStep(
|
||||
currentRun.id,
|
||||
'health-check',
|
||||
'success',
|
||||
);
|
||||
currentRun = await this.advanceNotification(currentRun, 'succeeded');
|
||||
currentRun = await this.completeStep(currentRun.id, 'finish-release', 'success');
|
||||
currentRun = await this.completeStep(
|
||||
currentRun.id,
|
||||
'finish-release',
|
||||
'success',
|
||||
);
|
||||
currentRun = this.requireRun(
|
||||
currentRun.id,
|
||||
await this.deployRunRepository.updateRun(currentRun.id, {
|
||||
@@ -382,6 +418,7 @@ export class DeployExecutionService {
|
||||
let currentRun =
|
||||
(await this.deployRunRepository.updateStep(run.id, 'jenkins-build', {
|
||||
status: 'failed',
|
||||
message: undefined,
|
||||
errorSummary: failureSummary,
|
||||
logExcerpt,
|
||||
})) ?? run;
|
||||
@@ -473,6 +510,7 @@ export class DeployExecutionService {
|
||||
runId,
|
||||
await this.deployRunRepository.updateStep(runId, bpmnNodeId, {
|
||||
status,
|
||||
message: undefined,
|
||||
errorSummary,
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user