From c80cba846b022eb2a074ae4ec5711a094755b246 Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@seco.com> Date: Thu, 19 Oct 2023 12:16:44 +0200 Subject: [PATCH] Cancel all pipelines on newer commit We already canceled running pipelines before. Gitlab, however, might have already canceled previous pipelines automatically, but without canceling their child pipelines. Remove the "running" status filter when cancelling pipelines, so that also already cancelled pipelines will be included. --- scripts/cancel_pipelines.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/cancel_pipelines.py b/scripts/cancel_pipelines.py index acea143e..b894b0df 100755 --- a/scripts/cancel_pipelines.py +++ b/scripts/cancel_pipelines.py @@ -46,11 +46,11 @@ def cancel_pipelines( ref: str = "", below_pipeline_id: int = sys.maxsize, ) -> list[ProjectPipeline]: - """Cancel currently running pipelines. + """Cancel GitLab pipelines. Args: project: GitLab project the pipeline belongs to - ref: Git ref (branch or tag) the pipeline is running on + ref: Git ref (branch or tag) the pipeline belongs to below_pipeline_id: cancel only pipelines with ID below this Returns: @@ -58,7 +58,7 @@ def cancel_pipelines( """ pipelines = project.pipelines.list( - ref=ref, status="running", as_list=False, retry_transient_errors=True + ref=ref, as_list=False, retry_transient_errors=True ) cancelled_pipelines = [] @@ -117,7 +117,7 @@ def main(): cancelled_pipelines = cancel_pipelines(project, args.ref, args.below_pipeline_id) if not cancelled_pipelines: - print("No running pipelines found.") + print("No pipelines found.") sys.exit(0) print("Cancelled pipelines:") -- GitLab