diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts
index 667ec3cfb..f9fd1d8ed 100644
--- a/packages/core/pipeline/src/core/executor.ts
+++ b/packages/core/pipeline/src/core/executor.ts
@@ -52,8 +52,10 @@ export class Executor {
this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline);
}
- cancel() {
+ async cancel() {
this.canceled = true;
+ this.runtime?.cancel(this.pipeline);
+ await this.onChanged(this.runtime);
}
async run(runtimeId: any = 0, triggerType: string) {
diff --git a/packages/core/pipeline/src/core/run-history.ts b/packages/core/pipeline/src/core/run-history.ts
index 855deffb1..8fa378378 100644
--- a/packages/core/pipeline/src/core/run-history.ts
+++ b/packages/core/pipeline/src/core/run-history.ts
@@ -92,6 +92,19 @@ export class RunHistory {
this.logError(runnable, e);
}
+ cancel(runnable: Runnable) {
+ const now = new Date().getTime();
+ const status = runnable.status;
+ _.merge(status, {
+ status: ResultType.canceled,
+ endTime: now,
+ result: ResultType.canceled,
+ message: "用户取消",
+ });
+
+ this.log(runnable, "任务取消");
+ }
+
log(runnable: Runnable, text: string) {
// @ts-ignore
this._loggers[runnable.id].info(`[${runnable.title}] [${runnable.runnableType}]`, text);
diff --git a/packages/core/pipeline/src/d.ts/pipeline.ts b/packages/core/pipeline/src/d.ts/pipeline.ts
index a73497c2f..148c12cec 100644
--- a/packages/core/pipeline/src/d.ts/pipeline.ts
+++ b/packages/core/pipeline/src/d.ts/pipeline.ts
@@ -106,6 +106,7 @@ export enum ResultType {
start = "start",
success = "success",
error = "error",
+ canceled = "canceled",
skip = "skip",
none = "none",
}
diff --git a/packages/ui/certd-client/src/views/certd/pipeline/api.ts b/packages/ui/certd-client/src/views/certd/pipeline/api.ts
index 948d0049d..ffc64ffd8 100644
--- a/packages/ui/certd-client/src/views/certd/pipeline/api.ts
+++ b/packages/ui/certd-client/src/views/certd/pipeline/api.ts
@@ -67,6 +67,14 @@ export function Trigger(id: any) {
});
}
+export function Cancel(historyId: any) {
+ return request({
+ url: apiPrefix + "/cancel",
+ method: "post",
+ params: { historyId }
+ });
+}
+
export async function GetFiles(pipelineId: number) {
return request({
url: historyApiPrefix + "/files",
diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue
index 6b8ec8489..11568b9d5 100644
--- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue
+++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue
@@ -9,6 +9,8 @@
当前
查看
+
+ 取消
@@ -16,6 +18,8 @@