Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Last active January 17, 2025 00:21
Show Gist options
  • Save TerrorJack/e0e886b87b9bfffb6c5fa5b3aeddcecc to your computer and use it in GitHub Desktop.
Save TerrorJack/e0e886b87b9bfffb6c5fa5b3aeddcecc to your computer and use it in GitHub Desktop.
#!/usr/bin/env -S deno run --allow-env --allow-net
import { Gitlab } from "npm:@gitbeaker/[email protected]";
const api = new Gitlab({
host: "https://gitlab.haskell.org",
token: Deno.env.get("GITLAB_TOKEN"),
});
async function cancel(projectId, pipelineId) {
const jobs = (
await api.Jobs.all(projectId, {
pipelineId,
perPage: 100,
})
).filter((job) => job.stage === "full-build" && !job.name.includes("wasm"));
for (const job of jobs) {
try {
await api.Jobs.cancel(projectId, job.id);
console.log(`[INFO] Cancelled ${job.name}`);
} catch (err) {
console.warn(`[WARN] Error cancelling ${job.name}: ${err}`);
}
}
}
await cancel(Deno.env.get("CI_PROJECT_ID"), Deno.env.get("CI_PIPELINE_ID"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment