@@ -77,35 +77,15 @@ jobs:
7777
7878 print_new_logs() {
7979 local json="$1"
80- echo "[DEBUG] print_new_logs called, json length: ${#json}"
81- if [ -z "$json" ]; then
82- echo "[DEBUG] json is empty, returning"
83- return
84- fi
85-
86- # Check if .result.lines exists
87- has_lines=$(echo "$json" | jq '.result | has("lines")' 2>/dev/null || echo "false")
88- echo "[DEBUG] has .result.lines key: $has_lines"
89-
90- # Check top-level keys
91- echo "[DEBUG] top-level keys: $(echo "$json" | jq -r 'keys | join(", ")' 2>/dev/null || echo "PARSE ERROR")"
92- echo "[DEBUG] result keys: $(echo "$json" | jq -r '.result | keys | join(", ")' 2>/dev/null || echo "PARSE ERROR")"
80+ if [ -z "$json" ]; then return; fi
9381
9482 total_lines=$(echo "$json" | jq '.result.lines | length' 2>/dev/null || echo "0")
95- echo "[DEBUG] total_lines=$total_lines last_line_count=$last_line_count"
9683
9784 if [ "$total_lines" -gt "$last_line_count" ]; then
98- echo "[DEBUG] printing lines from $last_line_count to $total_lines"
99- # Print first line raw for debugging
100- echo "[DEBUG] first new line raw: $(echo "$json" | jq --argjson skip "$last_line_count" '.result.lines[$skip:][0]' 2>/dev/null)"
10185 echo "$json" | jq -r \
10286 --argjson skip "$last_line_count" \
10387 '.result.lines[$skip:][] | .[1]'
104- jq_exit=$?
105- echo "[DEBUG] jq exit code: $jq_exit"
10688 last_line_count=$total_lines
107- else
108- echo "[DEBUG] no new lines to print"
10989 fi
11090 }
11191
@@ -155,36 +135,26 @@ jobs:
155135 outcome=$(echo "$build_data" | jq -r '.build_outcome // empty')
156136
157137 # Fetch and print new log lines
158- echo "[DEBUG] Fetching logs for build ${build_uuid}..."
159- logs_json=$(curl -s \
138+ logs_json=$(curl -sf \
160139 "${API_BASE}/builds/builds/${build_uuid}/logs" \
161140 -H "$AUTH_HEADER" \
162141 ) 2>/dev/null || logs_json=""
163- logs_curl_exit=$?
164- echo "[DEBUG] logs curl exit code: $logs_curl_exit, response length: ${#logs_json}"
165- echo "[DEBUG] logs first 500 chars: ${logs_json:0:500}"
166142
167143 print_new_logs "$logs_json"
168144
169145 # When a build finishes, status becomes "stopped" and the
170146 # result is in build_outcome (success, fail, skipped, cancelled, terminated).
171147 if [ "$status" = "stopped" ]; then
172- echo "[DEBUG] Build is stopped, outcome=$outcome"
173148 # Do a final log fetch to make sure we got everything
174149 sleep 2
175- echo "[DEBUG] Doing final log fetch..."
176- final_logs=$(curl -s \
150+ final_logs=$(curl -sf \
177151 "${API_BASE}/builds/builds/${build_uuid}/logs" \
178152 -H "$AUTH_HEADER" \
179153 ) 2>/dev/null || final_logs=""
180- echo "[DEBUG] final_logs length: ${#final_logs}"
181- echo "[DEBUG] final_logs first 500 chars: ${final_logs:0:500}"
182154
183155 if [ -n "$final_logs" ]; then
184156 print_new_logs "$final_logs"
185157 print_build_phases "$final_logs"
186- else
187- echo "[DEBUG] final_logs is empty!"
188158 fi
189159
190160 echo ""
0 commit comments