fix: 清理 Jenkins 日志控制片段
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user