perf: 优化钉钉通知标题颜色

pull/409/head
xiaojunnuo 2025-05-17 01:13:36 +08:00
parent a818a3d293
commit a560999d13
2 changed files with 7 additions and 5 deletions

View File

@ -218,7 +218,7 @@ export class Executor {
returnType: ResultType.error, returnType: ResultType.error,
runnable: t, runnable: t,
}); });
errorMessage += `任务${t.title}执行失败,错误详情:${e.message}`; errorMessage += `任务${t.title}执行失败,错误详情${e.message}`;
} }
} }
if (errorList.length > 0) { if (errorList.length > 0) {
@ -438,7 +438,7 @@ export class Executor {
const runnableError = error as RunnableError; const runnableError = error as RunnableError;
content = `流水线ID:${this.pipeline.id}运行ID:${this.runtime.id}\n\n`; content = `流水线ID:${this.pipeline.id}运行ID:${this.runtime.id}\n\n`;
for (const re of runnableError.errors) { for (const re of runnableError.errors) {
content += ` - ${re.runnable.title} 执行失败,错误详情:${re.e?.error?.message}\n\n`; content += ` - ${re.runnable.title} 执行失败,错误详情${re.e?.error?.message}\n\n`;
} }
} else { } else {
content = `流水线ID:${this.pipeline.id}运行ID:${this.runtime.id}\n\n${this.currentStatusMap?.currentStep?.title} 执行失败\n\n错误详情:${error.message}`; content = `流水线ID:${this.pipeline.id}运行ID:${this.runtime.id}\n\n${this.currentStatusMap?.currentStep?.title} 执行失败\n\n错误详情:${error.message}`;

View File

@ -125,15 +125,17 @@ export class DingTalkNotification extends BaseNotification {
at.isAtAll = true; at.isAtAll = true;
} }
const color = body.errorMessage?'red':'green';
const res = await this.http.request({ const res = await this.http.request({
url: webhook, url: webhook,
method: 'POST', method: 'POST',
data: { data: {
at: at, at: at,
text: { markdown: {
content: `${body.title}\n${body.content}\n查看详情: ${body.url}`, title: body.title,
text: `<font color='${color}'>${body.title}</font>\n\n\n ${body.content}\n\n\n[查看详情](${body.url})`,
}, },
msgtype:"text" msgtype:"markdown"
}, },
}); });
if(res.errcode>100){ if(res.errcode>100){