diff --git a/apps/demo-nginx/Jenkinsfile b/apps/demo-nginx/Jenkinsfile index b9d57c0..5c3c19b 100644 --- a/apps/demo-nginx/Jenkinsfile +++ b/apps/demo-nginx/Jenkinsfile @@ -291,38 +291,32 @@ EOF stage('Wait for ArgoCD Sync') { steps { script { - echo "⏳ Waiting for ArgoCD to apply GitOps state..." + echo "⏳ Waiting for ArgoCD to apply GitOps image..." - def expectedRevision = sh( - script: "git -C k3s-gitops rev-parse HEAD", - returnStdout: true - ).trim() - - for (int i = 1; i <= 12; i++) { - - def argoRevision = sh( - script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.sync.revision}'", - returnStdout: true - ).trim() + for (int i = 1; i <= 18; i++) { def syncStatus = sh( script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.sync.status}'", returnStdout: true ).trim() - echo "Expected GitOps revision : ${expectedRevision}" - echo "ArgoCD applied revision : ${argoRevision}" - echo "ArgoCD sync status : ${syncStatus}" + def images = sh( + script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.summary.images}'", + returnStdout: true + ).trim() - if (syncStatus == "Synced" && argoRevision == expectedRevision) { - echo "✅ ArgoCD successfully synced Git revision" + echo "ArgoCD sync status : ${syncStatus}" + echo "ArgoCD images : ${images}" + + if (syncStatus == "Synced" && images.contains(IMAGE_TAG)) { + echo "✅ ArgoCD successfully applied image ${IMAGE_TAG}" return } sleep 10 } - error("❌ ArgoCD did not apply expected Git revision in time") + error("❌ ArgoCD did not apply image ${IMAGE_TAG} in time") } } } @@ -333,6 +327,7 @@ EOF + stage('Wait for Deployment') { when { branch 'main' }