From e3a954080b1150ae35c403cffdb71ae750c9a741 Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Mon, 1 Jul 2024 19:56:11 +0200
Subject: [PATCH] fix(Trivy): Trivy 0.53.0 added the clean subcommand for
 semantic cache management

---
 templates/gitlab-ci-docker.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/gitlab-ci-docker.yml b/templates/gitlab-ci-docker.yml
index c399c43..204e97a 100644
--- a/templates/gitlab-ci-docker.yml
+++ b/templates/gitlab-ci-docker.yml
@@ -930,7 +930,7 @@ docker-trivy:
     TRIVY_CACHE_DIR: ".trivycache/"
   script: |
     # cache cleanup is needed when scanning images with the same tags, it does not remove the database
-    trivy image --clear-cache
+    trivy clean --scan-cache || trivy image --clear-cache
     export TRIVY_USERNAME=${DOCKER_REGISTRY_SNAPSHOT_USER:-${DOCKER_REGISTRY_USER:-$CI_REGISTRY_USER}}
     export TRIVY_PASSWORD=${DOCKER_REGISTRY_SNAPSHOT_PASSWORD:-${DOCKER_REGISTRY_PASSWORD:-$CI_REGISTRY_PASSWORD}}
     basename=$(echo "${DOCKER_SNAPSHOT_IMAGE}" | sed 's|[/:]|_|g')
-- 
GitLab