mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
feat: 邮件通知
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
"name": "@certd/pipeline",
|
||||
"private": false,
|
||||
"version": "1.0.6",
|
||||
"main": "./dist/bundle.js",
|
||||
"module": "./dist/pipeline.mjs",
|
||||
"types": "./dist/d/index.d.ts",
|
||||
"main": "./src",
|
||||
"module": "./src",
|
||||
"types": "./src",
|
||||
"publishConfig": {
|
||||
"main": "./dist/bundle.js",
|
||||
"module": "./dist/bundle.mjs",
|
||||
@@ -19,6 +19,7 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"node-forge": "^1.3.1",
|
||||
"nodemailer": "^6.9.3",
|
||||
"qs": "^6.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ConcurrencyStrategy, NotificationType, NotificationWhen, Pipeline, ResultType, Runnable, RunStrategy, Stage, Step, Task } from "../d.ts";
|
||||
import { ConcurrencyStrategy, NotificationWhen, Pipeline, ResultType, Runnable, RunStrategy, Stage, Step, Task } from "../d.ts";
|
||||
import _ from "lodash";
|
||||
import { RunHistory, RunnableCollection } from "./run-history";
|
||||
import { AbstractTaskPlugin, PluginDefine, pluginRegistry } from "../plugin";
|
||||
@@ -216,13 +216,13 @@ export class Executor {
|
||||
let subject = "";
|
||||
let content = "";
|
||||
if (when === "start") {
|
||||
subject = `【CertD】${this.pipeline.title} 开始执行,buildId:${this.runtime.id}`;
|
||||
content = `【CertD】${this.pipeline.title} 开始执行,buildId:${this.runtime.id}`;
|
||||
subject = `【CertD】开始执行,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = subject;
|
||||
} else if (when === "success") {
|
||||
subject = `【CertD】${this.pipeline.title} 执行成功,buildId:${this.runtime.id}`;
|
||||
content = `【CertD】${this.pipeline.title} 执行成功,buildId:${this.runtime.id}`;
|
||||
subject = `【CertD】执行成功,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = subject;
|
||||
} else if (when === "error") {
|
||||
subject = `【CertD】${this.pipeline.title} 执行失败,buildId:${this.runtime.id}`;
|
||||
subject = `【CertD】执行失败,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = `<pre>${error.message}</pre>`;
|
||||
} else {
|
||||
return;
|
||||
@@ -234,6 +234,7 @@ export class Executor {
|
||||
}
|
||||
if (notification.type === "email") {
|
||||
this.options.emailService?.send({
|
||||
userId: this.pipeline.userId,
|
||||
subject,
|
||||
content,
|
||||
receivers: notification.options.receivers,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export type EmailSend = {
|
||||
userId: number;
|
||||
subject: string;
|
||||
content: string;
|
||||
receivers: string[];
|
||||
};
|
||||
|
||||
export interface IEmailService {
|
||||
send(email: EmailSend): Promise<void>;
|
||||
}
|
||||
@@ -1,9 +1 @@
|
||||
export type EmailSend = {
|
||||
subject: string;
|
||||
content: string;
|
||||
receivers: string[];
|
||||
};
|
||||
|
||||
export interface IEmailService {
|
||||
send(email: EmailSend): Promise<void>;
|
||||
}
|
||||
export * from "./email";
|
||||
|
||||
Reference in New Issue
Block a user