Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/current/netlify/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -o pipefail # Ensure pipeline exits with first failed command's exit code

echo "🚀 NETLIFY BUILD SCRIPT WITH RETRY LOGIC"
echo "========================================"
Expand All @@ -12,6 +13,12 @@ echo ""
MAX_RETRIES=${MAX_RETRIES:-3}
BASE_RETRY_DELAY=${BASE_RETRY_DELAY:-30}

# Testing: Simulate network errors to verify retry logic
# Set SIMULATE_NETWORK_ERROR=1 to test retry behavior
# Set SIMULATE_NETWORK_ERROR_ATTEMPTS=N to fail first N attempts (default: 1)
SIMULATE_NETWORK_ERROR=${SIMULATE_NETWORK_ERROR:-0}
SIMULATE_NETWORK_ERROR_ATTEMPTS=${SIMULATE_NETWORK_ERROR_ATTEMPTS:-1}

if [[ $MAX_RETRIES -gt 1 ]]; then
echo "🔄 RETRY LOGIC ENABLED"
echo "Max retries: ${MAX_RETRIES}"
Expand All @@ -20,6 +27,11 @@ else
echo "📋 SINGLE ATTEMPT BUILD"
fi

if [[ "$SIMULATE_NETWORK_ERROR" == "1" ]]; then
echo "🧪 TESTING MODE: Network error simulation enabled"
echo " Will simulate failure for first ${SIMULATE_NETWORK_ERROR_ATTEMPTS} attempt(s)"
fi

echo ""

# Build monitoring variables
Expand Down Expand Up @@ -65,11 +77,24 @@ function log_attempt() {
function build_with_monitoring {
local config=$1
local build_log="build_${ATTEMPT_COUNT}.log"

echo "📝 Starting Jekyll build with config: $config"
echo "⏰ Build start: $(date)"
echo "📄 Build log: $build_log"


# Testing: Simulate network error if enabled
if [[ "$SIMULATE_NETWORK_ERROR" == "1" && $ATTEMPT_COUNT -le $SIMULATE_NETWORK_ERROR_ATTEMPTS ]]; then
echo "🧪 TESTING: Simulating network error (attempt $ATTEMPT_COUNT of $SIMULATE_NETWORK_ERROR_ATTEMPTS simulated failures)"
echo "Liquid Exception: Failed to open TCP connection to raw.githubusercontent.com:443 (getaddrinfo: Temporary failure in name resolution)" | tee "$build_log"
echo "⏰ Build end: $(date)"
echo "❌ Jekyll build failed with exit code: 1 (simulated)"
echo "🔍 Analyzing build errors for retry eligibility..."
echo "🌐 Transient network error detected - eligible for retry"
echo "📋 Network error details:"
grep -iE "(temporary failure in name resolution|failed to open tcp connection)" "$build_log" | head -3
return 2 # Retryable error
fi

# Capture Jekyll output for error analysis
if bundle exec jekyll build --trace --config _config_base.yml,$config 2>&1 | tee "$build_log"; then
echo "⏰ Build end: $(date)"
Expand Down
Loading