Skip to content
Snippets Groups Projects
Commit 3697b4ea authored by Tim Jaacks's avatar Tim Jaacks
Browse files

cancel_pipelines: reverse order of cancellation

Cancel parent pipeline first before cancelling its children in order not
to have failed parent pipelines (trigger jobs are failed if their
downstream pipeline is cancelled).
parent 5f4ca2fb
No related branches found
No related tags found
1 merge request!358cancel_pipelines: reverse order of cancellation
Pipeline #87670 passed with stage
in 27 minutes and 9 seconds
......@@ -24,6 +24,10 @@ def cancel_pipeline_including_children(
cancelled_pipelines = []
if pipeline.status not in ["success", "failed", "canceled"]:
cancelled_pipelines.append(pipeline)
pipeline.cancel()
# Browse through all downstream pipelines
for bridge in pipeline.bridges.list(as_list=False):
......@@ -41,10 +45,6 @@ def cancel_pipeline_including_children(
cancelled_pipelines += cancel_pipeline_including_children(
project, downstream_pipeline
)
if downstream_pipeline.status not in ["success", "failed", "canceled"]:
cancelled_pipelines.append(downstream_pipeline)
pipeline.cancel()
return cancelled_pipelines
......@@ -73,8 +73,6 @@ def cancel_pipelines(
for pipeline in pipelines:
if pipeline.id < below_pipeline_id:
cancelled_pipelines += cancel_pipeline_including_children(project, pipeline)
if pipeline.status not in ["success", "failed", "canceled"]:
cancelled_pipelines.append(pipeline)
return cancelled_pipelines
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment