update: jenkinsfile code for multibranch pipeline

This commit is contained in:
adelyaou 2025-10-24 13:36:47 +07:00
parent 151c8970c4
commit a2a9ac5ac2
1 changed files with 9 additions and 9 deletions

16
Jenkinsfile vendored
View File

@ -55,24 +55,24 @@ pipeline {
echo "Cleaning overlays folder, keeping only ${overlayEnv}..." echo "Cleaning overlays folder, keeping only ${overlayEnv}..."
for d in overlays/*; do for d in overlays/*; do
[ -d "\\\$d" ] || continue [ -d "\$d" ] || continue
if [ "\\\$(basename "\\\$d")" != "${overlayEnv}" ]; then if [ "\$(basename \"\$d\")" != "${overlayEnv}" ]; then
echo "Removing \\\$d" echo "Removing \$d"
rm -rf "\\\$d" rm -rf "\$d"
fi fi
done done
echo "Updating image tags for ${overlayEnv}..." echo "Updating image tags for ${overlayEnv}..."
yq e -i '(.spec.template.spec.containers[] | select(.name == "backend") | .image) = "${REGISTRY}/${APP_NAME}-be:${IMAGE_TAG_FINAL}"' overlays/${overlayEnv}/patch-deployment.yaml 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
yq e -i '(.spec.template.spec.containers[] | select(.name == "frontend") | .image) = "${REGISTRY}/${APP_NAME}-fe:${IMAGE_TAG_FINAL}"' overlays/${overlayEnv}/patch-deployment.yaml yq e -i '(.spec.template.spec.containers[] | select(.name == "frontend") | .image) = "${REGISTRY}/${APP_NAME}-fe:${overlayEnv}-${env.IMAGE_TAG_FINAL}"' overlays/${overlayEnv}/patch-deployment.yaml
git config user.email "jenkins@automation.local" git config user.email "jenkins@automation.local"
git config user.name "Jenkins CI" git config user.name "Jenkins CI"
git add overlays/${overlayEnv}/patch-deployment.yaml git add overlays/${overlayEnv}/patch-deployment.yaml
git commit -m "chore(${overlayEnv}): update image tags to ${IMAGE_TAG_FINAL}" || echo "No changes to commit" git commit -m "chore(${overlayEnv}): update image tags to ${overlayEnv}-${env.IMAGE_TAG_FINAL}" || echo "No changes to commit"
echo "Pushing updates to branch ${overlayEnv}" echo "Pushing updates to branch ${overlayEnv}"
git push https://\${GIT_USER}:\${GIT_PASS}@${MANIFEST_REPO.replace('https://', '')} ${overlayEnv} || echo "No push needed for ${overlayEnv}" git push https://\$GIT_USER:\$GIT_PASS@${env.MANIFEST_REPO.replace('https://', '')} ${overlayEnv} || echo "No push needed for ${overlayEnv}"
""" """
} }
} }