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

14
Jenkinsfile vendored
View File

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