fix: preserve buildx logs on pipeline failure

This commit is contained in:
2026-05-06 13:32:31 +08:00
parent 9ba85b01f3
commit 5b507901db
Vendored
+8
View File
@@ -95,13 +95,21 @@ pipeline {
fi
sleep 20
done
set +e
wait "$cmd_pid"
cmd_status=$?
set -e
if [ -f "$log_file" ]; then
total_lines=$(wc -l < "$log_file" || echo 0)
if [ "$total_lines" -gt "$last_line" ]; then
sed -n "$((last_line + 1)),${total_lines}p" "$log_file"
fi
if [ "$cmd_status" -ne 0 ] && [ -s "$log_file" ]; then
echo "[captured-log] Full buildx log follows because the command failed:"
cat "$log_file"
fi
fi
return "$cmd_status"
}
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then