update: jenkinsfile code for multibranch pipeline

This commit is contained in:
adelyaou 2025-10-24 11:51:32 +07:00
parent 859b0ce173
commit ab05c4fcb4
1 changed files with 10 additions and 10 deletions

20
Jenkinsfile vendored
View File

@ -36,7 +36,7 @@ pipeline {
script {
def gitBranch = env.BRANCH_NAME ?: sh(script: "git rev-parse --abbrev-ref HEAD", returnStdout: true).trim()
def tag = "${gitBranch}-build-${env.BUILD_NUMBER}"
echo "🛠 Building and pushing Docker images with tag: ${tag}"
echo "Building and pushing Docker images with tag: ${tag}"
withCredentials([usernamePassword(credentialsId: env.DOCKER_CRED_ID, usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
sh """
@ -80,14 +80,14 @@ pipeline {
dir("${MANIFEST_DIR}-${overlayEnv}") {
sh """
set -e
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 "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
@ -115,7 +115,7 @@ pipeline {
stage('ArgoCD Sync (optional)') {
steps {
echo "If ArgoCD auto-sync is enabled, updates will deploy automatically."
echo "If ArgoCD auto-sync is enabled, updates will deploy automatically."
}
}
}