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() }