fix: preserve buildx logs on pipeline failure
This commit is contained in:
Vendored
+8
@@ -95,13 +95,21 @@ pipeline {
|
|||||||
fi
|
fi
|
||||||
sleep 20
|
sleep 20
|
||||||
done
|
done
|
||||||
|
set +e
|
||||||
wait "$cmd_pid"
|
wait "$cmd_pid"
|
||||||
|
cmd_status=$?
|
||||||
|
set -e
|
||||||
if [ -f "$log_file" ]; then
|
if [ -f "$log_file" ]; then
|
||||||
total_lines=$(wc -l < "$log_file" || echo 0)
|
total_lines=$(wc -l < "$log_file" || echo 0)
|
||||||
if [ "$total_lines" -gt "$last_line" ]; then
|
if [ "$total_lines" -gt "$last_line" ]; then
|
||||||
sed -n "$((last_line + 1)),${total_lines}p" "$log_file"
|
sed -n "$((last_line + 1)),${total_lines}p" "$log_file"
|
||||||
fi
|
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
|
fi
|
||||||
|
return "$cmd_status"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
if ! sudo docker buildx inspect --builder ${BUILDER_NAME} >/dev/null 2>&1; then
|
||||||
|
|||||||
Reference in New Issue
Block a user