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