Update apps/demo-nginx/Jenkinsfile

This commit is contained in:
2026-01-08 14:42:09 +00:00
parent 9d80731309
commit 09bd4b9e81

View File

@@ -291,38 +291,32 @@ EOF
stage('Wait for ArgoCD Sync') { stage('Wait for ArgoCD Sync') {
steps { steps {
script { script {
echo "⏳ Waiting for ArgoCD to apply GitOps state..." echo "⏳ Waiting for ArgoCD to apply GitOps image..."
def expectedRevision = sh( for (int i = 1; i <= 18; i++) {
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()
def syncStatus = sh( def syncStatus = sh(
script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.sync.status}'", script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.sync.status}'",
returnStdout: true returnStdout: true
).trim() ).trim()
echo "Expected GitOps revision : ${expectedRevision}" def images = sh(
echo "ArgoCD applied revision : ${argoRevision}" script: "kubectl get application demo-nginx -n argocd -o jsonpath='{.status.summary.images}'",
echo "ArgoCD sync status : ${syncStatus}" returnStdout: true
).trim()
if (syncStatus == "Synced" && argoRevision == expectedRevision) { echo "ArgoCD sync status : ${syncStatus}"
echo "ArgoCD successfully synced Git revision" 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 Git revision in time") error("❌ ArgoCD did not apply image ${IMAGE_TAG} in time")
} }
} }
} }
@@ -334,6 +328,7 @@ EOF
stage('Wait for Deployment') { stage('Wait for Deployment') {
when { branch 'main' } when { branch 'main' }
steps { steps {