Update apps/demo-nginx/Jenkinsfile
This commit is contained in:
31
apps/demo-nginx/Jenkinsfile
vendored
31
apps/demo-nginx/Jenkinsfile
vendored
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,6 +328,7 @@ EOF
|
||||
|
||||
|
||||
|
||||
|
||||
stage('Wait for Deployment') {
|
||||
when { branch 'main' }
|
||||
steps {
|
||||
|
||||
Reference in New Issue
Block a user