update: jenkinsfile code for multibranch pipeline

This commit is contained in:
adelyaou 2025-10-24 11:40:37 +07:00
parent f0f871369f
commit 859b0ce173
1 changed files with 8 additions and 2 deletions

10
Jenkinsfile vendored
View File

@ -80,8 +80,14 @@ pipeline {
dir("${MANIFEST_DIR}-${overlayEnv}") {
sh """
set -e
echo "Cleaning up overlays folder to only keep ${overlayEnv}"
find overlays -mindepth 1 -maxdepth 1 -type d ! -name "${overlayEnv}" -exec rm -rf {} +
echo "🧹 Cleaning overlays folder, keeping only ${overlayEnv}..."
for d in overlays/*; do
[ -d "$d" ] || continue
if [ "$(basename "$d")" != "${overlayEnv}" ]; then
echo "Removing $d"
rm -rf "$d"
fi
done
echo "Updating image tags for ${overlayEnv}..."
yq e -i '(.spec.template.spec.containers[] | select(.name == "backend") | .image) = "${REGISTRY}/${APP_NAME}-be:${overlayEnv}-${env.IMAGE_TAG_FINAL}"' overlays/${overlayEnv}/patch-deployment.yaml