Update apps/demo-nginx/Jenkinsfile

This commit is contained in:
2026-01-08 13:17:32 +00:00
parent ea9fbb4eb0
commit b6bee8c770

View File

@@ -291,7 +291,7 @@ EOF
stage('Wait for ArgoCD Sync') { stage('Wait for ArgoCD Sync') {
steps { steps {
script { script {
echo "⏳ Waiting for ArgoCD to apply GitOps revision..." echo "⏳ Waiting for ArgoCD to apply GitOps image..."
def expectedRevision = sh( def expectedRevision = sh(
script: "git -C k3s-gitops rev-parse HEAD", script: "git -C k3s-gitops rev-parse HEAD",
@@ -309,19 +309,26 @@ EOF
returnStdout: true returnStdout: true
).trim() ).trim()
echo "Expected GitOps revision : ${expectedRevision}" echo "Expected image tag : ${IMAGE_TAG}"
echo "ArgoCD applied revision : ${argoRevision}" echo "ArgoCD applied revision : ${argoRevision}"
echo "ArgoCD sync status : ${syncStatus}" echo "ArgoCD sync status : ${syncStatus}"
if (syncStatus == "Synced" && argoRevision == expectedRevision) { def images = sh(
echo "✅ ArgoCD successfully applied GitOps revision" script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.summary.images}'",
returnStdout: true
).trim()
echo "ArgoCD images : ${images}"
if (syncStatus == "Synced" && images.contains("${IMAGE_TAG}")) {
echo "✅ ArgoCD successfully applied image ${IMAGE_TAG}"
return return
} }
sleep 10 sleep 10
} }
error("❌ ArgoCD did not apply expected GitOps revision in time") error("❌ ArgoCD did not apply expected image in time")
} }
} }
} }
@@ -331,6 +338,7 @@ EOF
stage('Wait for Deployment') { stage('Wait for Deployment') {
when { branch 'main' } when { branch 'main' }
steps { steps {