mirror of https://github.com/certd/certd
perf: 优化飞书通知为卡片模式
parent
905219e523
commit
a818a3d293
|
@ -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} 执行失败\n 错误详情:${re.e.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}`;
|
||||||
|
|
|
@ -98,11 +98,11 @@ export class DingTalkNotification extends BaseNotification {
|
||||||
if(nameIndex>0){
|
if(nameIndex>0){
|
||||||
name = id.substring(nameIndex+1)
|
name = id.substring(nameIndex+1)
|
||||||
}
|
}
|
||||||
return `<at user_id="${id}">${name}</at>`
|
return `<at id=${id}>${name}</at>`
|
||||||
}).join("");
|
}).join("");
|
||||||
}
|
}
|
||||||
if(this.isAtAll){
|
if(this.isAtAll){
|
||||||
atText = `<at user_id="all">所有人</at>`
|
atText = `<at id=all>所有人</at>`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (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({
|
const res = await this.http.request({
|
||||||
url: webhook,
|
url: webhook,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
...sign,
|
...sign,
|
||||||
content: {
|
...cardBody
|
||||||
text: `${body.title}\n${body.content}\n查看详情: ${body.url}${atText}`,
|
|
||||||
},
|
|
||||||
msg_type:"text"
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if(res.code>100){
|
if(res.code>100){
|
||||||
|
|
Loading…
Reference in New Issue