From 6333e64e61fb025ce758cdb275a6888d934b878b Mon Sep 17 00:00:00 2001
From: Timothy Stone <gitlab@petmystone.com>
Date: Mon, 1 Jul 2024 17:57:05 +0000
Subject: [PATCH] fix(Jib): Trivy 0.53.0 added the clean subcommand for
 semantic cache management

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

diff --git a/templates/gitlab-ci-maven-jib.yml b/templates/gitlab-ci-maven-jib.yml
index 395c91e..a6ca86c 100644
--- a/templates/gitlab-ci-maven-jib.yml
+++ b/templates/gitlab-ci-maven-jib.yml
@@ -159,7 +159,7 @@ mvn-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=${MAVEN_JIB_REGISTRY_SNAPSHOT_USER:-${MAVEN_JIB_REGISTRY_USER:-$CI_REGISTRY_USER}}
     export TRIVY_PASSWORD=${MAVEN_JIB_REGISTRY_SNAPSHOT_PASSWORD:-${MAVEN_JIB_REGISTRY_PASSWORD:-$CI_REGISTRY_PASSWORD}}
     export basename=$(echo "${MAVEN_JIB_SNAPSHOT_IMAGE}" | sed 's|[/:]|_|g')
-- 
GitLab