diff --git a/apps/demo-nginx/Jenkinsfile b/apps/demo-nginx/Jenkinsfile index e4dd897..4857cf6 100644 --- a/apps/demo-nginx/Jenkinsfile +++ b/apps/demo-nginx/Jenkinsfile @@ -291,7 +291,7 @@ EOF stage('Wait for ArgoCD Sync') { steps { script { - echo "⏳ Waiting for ArgoCD to apply GitOps revision..." + echo "⏳ Waiting for ArgoCD to apply GitOps image..." def expectedRevision = sh( script: "git -C k3s-gitops rev-parse HEAD", @@ -309,19 +309,26 @@ EOF returnStdout: true ).trim() - echo "Expected GitOps revision : ${expectedRevision}" + echo "Expected image tag : ${IMAGE_TAG}" echo "ArgoCD applied revision : ${argoRevision}" echo "ArgoCD sync status : ${syncStatus}" - if (syncStatus == "Synced" && argoRevision == expectedRevision) { - echo "✅ ArgoCD successfully applied GitOps revision" + def images = sh( + 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 } sleep 10 } - error("❌ ArgoCD did not apply expected GitOps revision in time") + error("❌ ArgoCD did not apply expected image in time") } } } @@ -330,6 +337,7 @@ EOF + stage('Wait for Deployment') { when { branch 'main' }