fix(rollback): Fix bash loop syntax for health check retries

This commit is contained in:
Claude AI
2026-01-06 08:33:30 +00:00
parent cec5cda986
commit f8eeeb3960

View File

@@ -242,7 +242,9 @@ pipeline {
script {
echo "🏥 Running health checks..."
sh """
sh """#!/bin/bash
set -e
# Check all pods are ready
READY_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.status.readyReplicas}')
DESIRED_PODS=\$(kubectl get deployment ${APP_NAME} -n ${NAMESPACE} -o jsonpath='{.spec.replicas}')
@@ -263,14 +265,16 @@ pipeline {
echo "Testing pod: \${POD_NAME}"
# Test health endpoint with retry
for i in {1..5}; do
for i in 1 2 3 4 5; do
echo "Health check attempt \$i/5..."
if kubectl exec \${POD_NAME} -n ${NAMESPACE} -- wget -q -O- http://localhost/health 2>/dev/null; then
echo "✅ Health check passed!"
exit 0
fi
if [ \$i -lt 5 ]; then
echo "Retrying in 5 seconds..."
sleep 5
fi
done
echo "❌ Health check failed after 5 attempts"