fix: 清理 Jenkins 日志控制片段

This commit is contained in:
湛兮
2026-06-12 02:41:47 +08:00
parent b41c9c902f
commit c9ce35c758
2 changed files with 26 additions and 2 deletions
+19 -1
View File
@@ -24,6 +24,16 @@ import {
DeployRunSummary,
} from './deploy-run.types';
const escapeControl = String.fromCharCode(27);
const jenkinsConsoleNotePattern = new RegExp(
`${escapeControl}\\[8mha:/{4}[A-Za-z0-9+/=]+${escapeControl}\\[0m`,
'g',
);
const ansiEscapePattern = new RegExp(
`${escapeControl}\\[[0-?]*[ -/]*[@-~]`,
'g',
);
@Injectable()
export class DeployRunsService {
constructor(
@@ -265,7 +275,9 @@ export class DeployRunsService {
run.jenkinsBuildNumber,
normalizedStart,
);
const text = redactSensitive({ text: log.text }).text;
const text = redactSensitive({
text: this.cleanJenkinsLogText(log.text),
}).text;
await this.auditService.record({
action: 'JENKINS_LOG_VIEWED',
@@ -390,6 +402,12 @@ export class DeployRunsService {
return value;
}
private cleanJenkinsLogText(text: string): string {
return text
.replace(jenkinsConsoleNotePattern, '')
.replace(ansiEscapePattern, '');
}
private async cancelJenkinsExecution(
run: DeployRunSummary,
project: ProjectSummary,