From 5b507901db5b2708fc7fcb8c8be755eb94c76a51 Mon Sep 17 00:00:00 2001 From: nanxun Date: Wed, 6 May 2026 13:32:31 +0800 Subject: [PATCH] fix: preserve buildx logs on pipeline failure --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fb5e0ad..e72bdfb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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