update: jenkinsfile code for multibranch pipeline
This commit is contained in:
parent
859b0ce173
commit
ab05c4fcb4
|
|
@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue