feat(pipeline-tasks): 添加 部署任务查询接口和任务日志推送。

This commit is contained in:
Ivan Li
2021-03-20 14:30:26 +08:00
parent 7923ae6d41
commit cdc28cb102
4 changed files with 39 additions and 8 deletions

View File

@@ -57,7 +57,12 @@ export class PipelineTaskConsumer {
}
for (const script of unit.scripts) {
unitLog.logs += `[RUN SCRIPT] ${script}`;
const messages = await this.runScript(script, workspaceRoot, task);
const messages = await this.runScript(
script,
workspaceRoot,
task,
unit.type,
);
unitLog.logs += messages.join('');
}
unitLog.status = TaskStatuses.success;
@@ -83,6 +88,7 @@ export class PipelineTaskConsumer {
script: string,
workspaceRoot: string,
task?: PipelineTask,
unit?: PipelineUnits,
): Promise<string[]> {
return new Promise((resolve, reject) => {
const errorMessages: string[] = [];
@@ -95,12 +101,16 @@ export class PipelineTaskConsumer {
const str = data.toString();
errorMessages.push(str);
logs.push(str);
this.logsService.recordLog(PipelineTaskLogMessage.create(task, str));
this.logsService.recordLog(
PipelineTaskLogMessage.create(task, unit, str),
);
});
sub.stdout.on('data', (data: Buffer) => {
const str = data.toString();
logs.push(str);
this.logsService.recordLog(PipelineTaskLogMessage.create(task, str));
this.logsService.recordLog(
PipelineTaskLogMessage.create(task, unit, str),
);
});
sub.addListener('close', (code) => {
if (code === 0) {