From b398dba6c1929ff45d9679af82f2ce363acf3155 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Fri, 9 Aug 2024 02:29:32 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=A4=84=E7=90=86=E4=BA=8B=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/managePipelineEvent/index.ts | 34 +++++++++++++----------- routes/event/index.ts | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/controllers/managePipelineEvent/index.ts b/controllers/managePipelineEvent/index.ts index 0aa1387..70d7196 100644 --- a/controllers/managePipelineEvent/index.ts +++ b/controllers/managePipelineEvent/index.ts @@ -281,21 +281,25 @@ const manageRawEvent = async ( const stage = params.get("stage") // 获取下一步操作 const action = await getNextAction(pipeline, stage) - // 发送通知 - if (action === NEXT_ACTION.NOTIFY) { - sendNotify(pipeline, apiKey) - } - // 添加监控 - if (action === NEXT_ACTION.ADD_MONITOR) { - addMonitor(pipeline, apiKey, stage!) - } - // 删除监控 - if (action === NEXT_ACTION.REMOVE_MONITOR) { - removeMonitor(pipeline, apiKey, stage!) - } - // 删除监控并发送通知 - if (action === NEXT_ACTION.NOTIFY_AND_REMOVE_MONITOR) { - removeMonitorAndNotify(pipeline, apiKey, stage!) + switch (action) { + // 发送通知 + case NEXT_ACTION.NOTIFY: + await sendNotify(pipeline, apiKey) + break + // 添加监控 + case NEXT_ACTION.ADD_MONITOR: + await addMonitor(pipeline, apiKey, stage!) + break + // 删除监控 + case NEXT_ACTION.REMOVE_MONITOR: + await removeMonitor(pipeline, apiKey, stage!) + break + // 删除监控并发送通知 + case NEXT_ACTION.NOTIFY_AND_REMOVE_MONITOR: + await removeMonitorAndNotify(pipeline, apiKey, stage!) + break + default: + break } // 返回成功 return netTool.ok() diff --git a/routes/event/index.ts b/routes/event/index.ts index 6344e05..a50c871 100644 --- a/routes/event/index.ts +++ b/routes/event/index.ts @@ -15,7 +15,7 @@ export const manageGitlabEventReq = async (req: Request): Promise => { if (eventType === "Pipeline Hook") { const body = (await req.json()) as Gitlab.PipelineEvent const params = new URLSearchParams(req.url.split("?")[1]) - return managePipelineEvent.manageRawEvent(body, apiKey, params) + return await managePipelineEvent.manageRawEvent(body, apiKey, params) } return netTool.ok() }