From 75116098cdc533003bf69639523dc986bfd1cc51 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck <wdconinc@gmail.com> Date: Sat, 25 May 2024 21:29:52 +0000 Subject: [PATCH] fix: don't clean pipelines created "<N> hours ago" --- .gitlab-ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3e115585..40aa058c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -540,7 +540,8 @@ prune: clean_internal_tag: image: alpine/curl stage: finalize - when: always + rules: + - when: manual script: - | for id in 66 68 69 80 83 91 92 97 ; do @@ -596,7 +597,7 @@ clean_pipeline: ; do docker images --filter=reference=${registry}/*:pipeline-* - --format "{{.ID}} {{.Repository}} {{.Tag}}" ; + --format "{{.ID}} {{.Repository}} {{.Tag}} {{.CreatedSince}}" ; done - for registry in eicweb @@ -604,11 +605,12 @@ clean_pipeline: ; do docker images --filter=reference=${registry}/*:pipeline-* - --format "{{.ID}} {{.Repository}} {{.Tag}}" ; + --format "{{.ID}} {{.Repository}} {{.Tag}} {{.CreatedSince}}" ; done | grep -v ${CI_PIPELINE_ID} - | sed -n -E 's/pipeline-([0-9]+)(-.*){0,1}$/& \1/p' - | while read id repository tag pipeline_id ; do + | grep -v "hours ago" + | sed -n -E 's/pipeline-([0-9]+)(-.*){0,1}\s+.*$/\1 &/p' + | while read id repository pipeline_id tag N durations ago ; do echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${pipeline_id}" ; curl --silent -L "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${pipeline_id}" | jq . ; status=$(curl --silent -L -- GitLab