fix(rollback): Use writeFile for proper variable substitution in HTML

This commit is contained in:
Claude AI
2026-01-06 09:21:46 +00:00
parent a21b2df4ef
commit 2d814639f1

View File

@@ -94,7 +94,7 @@ pipeline {
kubectl get pods -n ${NAMESPACE} -l app=${APP_NAME}
echo ""
echo "=== Rollout History ===\"
echo "=== Rollout History ==="
kubectl rollout history deployment/${APP_NAME} -n ${NAMESPACE}
"""
}
@@ -143,20 +143,15 @@ pipeline {
echo "🔨 Rebuilding image with updated design..."
// Create Dockerfile
sh """
cat > Dockerfile << 'EOF'
FROM nginx:1.25.3-alpine
writeFile file: 'Dockerfile', text: '''FROM nginx:1.25.3-alpine
COPY index.html /usr/share/nginx/html/index.html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
EOF
"""
'''
// Create HTML with rollback marker
sh """
cat > index.html << EOF
<!DOCTYPE html>
// Create HTML with proper variable substitution
def htmlContent = """<!DOCTYPE html>
<html>
<head>
<title>Demo Nginx - Rollback</title>
@@ -216,13 +211,12 @@ EOF
</div>
</body>
</html>
EOF
"""
writeFile file: 'index.html', text: htmlContent
// Create nginx.conf
sh '''
cat > nginx.conf << 'EOF'
user nginx;
writeFile file: 'nginx.conf', text: '''user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
@@ -250,7 +244,6 @@ http {
}
}
}
EOF
'''
// Build new image