From a818a3d293e22fb46979bc77055c05621a6fed81 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sat, 17 May 2025 00:47:28 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E9=A3=9E=E4=B9=A6?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=B8=BA=E5=8D=A1=E7=89=87=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/core/executor.ts | 2 +- .../plugin-notification/feishu/index.ts | 74 +++++++++++++++++-- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index c79dee66..a009ca39 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -438,7 +438,7 @@ export class Executor { const runnableError = error as RunnableError; content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}\n\n`; for (const re of runnableError.errors) { - content += ` - ${re.runnable.title} 执行失败\n 错误详情:${re.e.message}\n\n`; + content += ` - ${re.runnable.title} 执行失败,错误详情:${re.e?.error?.message}\n\n`; } } else { content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}\n\n${this.currentStatusMap?.currentStep?.title} 执行失败\n\n错误详情:${error.message}`; diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/feishu/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/feishu/index.ts index 031eb1c7..bc79c468 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/feishu/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/feishu/index.ts @@ -98,11 +98,11 @@ export class DingTalkNotification extends BaseNotification { if(nameIndex>0){ name = id.substring(nameIndex+1) } - return `${name}` + return `${name}` }).join(""); } if(this.isAtAll){ - atText = `所有人` + atText = `所有人` } if (atText){ @@ -118,16 +118,78 @@ export class DingTalkNotification extends BaseNotification { } } + const cardBody = { + "msg_type": "interactive", + "card": { + "schema": "2.0", + "config": { + "update_multi": true, + "style": { + "text_size": { + "normal_v2": { + "default": "normal", + "pc": "normal", + "mobile": "heading" + } + } + } + }, + "header": { + "title": { + "tag": "plain_text", + "content": body.title + }, + "subtitle": { + "tag": "plain_text", + "content": "" + }, + "template": body.errorMessage?"red":"green", + "padding": "12px 12px 12px 12px" + }, + "body": { + "direction": "vertical", + "padding": "12px 12px 12px 12px", + "elements": [ + { + "tag": "markdown", + "content": body.content+atText, + "text_align": "left", + "text_size": "normal_v2", + "margin": "0px 0px 0px 0px" + }, + { + "tag": "button", + "text": { + "tag": "plain_text", + "content": "查看详情" + }, + "type": "default", + "width": "default", + "size": "medium", + "behaviors": [ + { + "type": "open_url", + "default_url": body.url, + "pc_url": "", + "ios_url": "", + "android_url": "" + } + ], + "margin": "0px 0px 0px 0px" + } + ] + }, + + } + } + const res = await this.http.request({ url: webhook, method: 'POST', data: { ...sign, - content: { - text: `${body.title}\n${body.content}\n查看详情: ${body.url}${atText}`, - }, - msg_type:"text" + ...cardBody }, }); if(res.code>100){