From 1688d27b4e2dbc3aaa24cbc5dd9c5c63233239a7 Mon Sep 17 00:00:00 2001 From: Lai Jiang Date: Thu, 3 Feb 2022 16:04:58 -0500 Subject: [PATCH] Correctly delete all stopped versions except for the most recent 3 (#1511) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gcloud command does some weird stuff with sorting when custom format is used. Here we instead rely on linux sort and head command to sort the versions list. --- This change is [Reviewable](https://reviewable.io/reviews/google/nomulus/1511) --- release/cloudbuild-delete.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/cloudbuild-delete.yaml b/release/cloudbuild-delete.yaml index 32510a432..6a38aad0a 100644 --- a/release/cloudbuild-delete.yaml +++ b/release/cloudbuild-delete.yaml @@ -52,8 +52,8 @@ steps: do for version in $(gcloud app versions list \ --filter="SERVICE:$service AND SERVING_STATUS:STOPPED" \ - --sort-by=LAST_DEPLOYED --format="value(VERSION.ID)" \ - --project=$project_id | head -n -3) + --format="value(VERSION.ID,LAST_DEPLOYED)" \ + --project=$project_id | sort -k 2 | head -n -3) do gcloud app versions delete $version --service=$service \ --project=$project_id --quiet;