fix(pipeline-service): 修复流水线运行时超过套餐部署次数仍然能够正常运行的bug

This commit is contained in:
xiaojunnuo
2026-05-25 00:15:23 +08:00
parent 5e72f75395
commit 5e59651d45
2 changed files with 39 additions and 0 deletions
@@ -0,0 +1,38 @@
import assert from "assert";
import { PipelineEntity } from "../entity/pipeline.js";
import { PipelineService } from "./pipeline-service.js";
describe("PipelineService", () => {
it("does not start a pipeline run when beforeCheck fails", async () => {
const service = new PipelineService();
let historyStarted = false;
service.beforeCheck = async () => {
throw new Error("部署次数不足");
};
service.userService = {
async isAdmin() {
return false;
},
} as any;
service.historyService = {
async start() {
historyStarted = true;
throw new Error("history should not start");
},
} as any;
const entity = new PipelineEntity();
entity.id = 1;
entity.userId = 1;
entity.projectId = 0;
entity.content = JSON.stringify({
stages: [{ id: "stage1", tasks: [] }],
triggers: [],
});
await service.doRun(entity, null, "ALL");
assert.equal(historyStarted, false);
});
});
@@ -659,6 +659,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
suite = res.suite
} catch (e) {
logger.error(`流水线${entity.id}触发失败(${triggerId}):${e.message}`);
return;
}
const id = entity.id;