fix(rollback): Fix bash loop syntax for health check retries
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user