Skip to content

Commit 12f8d90

Browse files
mparamas-zzclaude
andcommitted
ci: stop set -e from aborting USB boot-entry detection
The PARTUUID match (Strategy 1) runs grep against efibootmgr output; when the USB entry has no HD(GPT,<partuuid>) device path, grep exits non-zero. Under set -euo pipefail that failing command substitution aborted the whole remote script right after printing the boot entries, before Strategy 2/3 or the error handler could run -- so the flash succeeded but the stage failed with no diagnostic (seen in run #84). Add `|| true` to the grep substitutions and lsblk calls so a legitimate no-match falls through to the next strategy. Simulated against real #84 efibootmgr output (resolves to the USB entry), a generic no-brand stick (USB-label match), and a no-USB host (reaches the error handler). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c26cf6f commit 12f8d90

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Jenkinsfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,26 +669,29 @@ USB_ENTRY=""
669669
670670
# Strategy 1: match a partition PARTUUID of the target device (works if the installer
671671
# wrote an ESP the firmware indexed as HD(GPT,<partuuid>)).
672-
for uuid in $(lsblk -no PARTUUID "$USB_DEVICE" 2>/dev/null); do
672+
# NOTE: each match uses `|| true` because a no-match grep exits non-zero, which under
673+
# `set -euo pipefail` would abort the whole script mid-detection before later strategies
674+
# (or the error handler below) get a chance to run.
675+
for uuid in $(lsblk -no PARTUUID "$USB_DEVICE" 2>/dev/null || true); do
673676
[ -z "$uuid" ] && continue
674-
m=$(echo "$EFI_OUT" | grep -iE "^Boot[0-9A-Fa-f]{4}.*${uuid}" | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//')
677+
m=$(echo "$EFI_OUT" | grep -iE "^Boot[0-9A-Fa-f]{4}.*${uuid}" | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//' || true)
675678
if [ -n "$m" ]; then USB_ENTRY="$m"; echo "Matched USB boot entry by PARTUUID ${uuid}."; break; fi
676679
done
677680
678681
# Strategy 2: match by the target device's model/vendor tokens (ties the entry to THIS
679682
# exact USB drive, avoiding a wrong pick if several USB entries exist).
680683
if [ -z "$USB_ENTRY" ]; then
681-
MODELVEND="$(lsblk -dno MODEL "$USB_DEVICE" 2>/dev/null) $(lsblk -dno VENDOR "$USB_DEVICE" 2>/dev/null)"
684+
MODELVEND="$(lsblk -dno MODEL "$USB_DEVICE" 2>/dev/null || true) $(lsblk -dno VENDOR "$USB_DEVICE" 2>/dev/null || true)"
682685
for tok in $(echo "$MODELVEND" | tr '_/.-' ' '); do
683686
[ ${#tok} -ge 4 ] || continue
684-
m=$(echo "$EFI_OUT" | grep -E '^Boot[0-9A-Fa-f]{4}' | grep -iF "$tok" | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//')
687+
m=$(echo "$EFI_OUT" | grep -E '^Boot[0-9A-Fa-f]{4}' | grep -iF "$tok" | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//' || true)
685688
if [ -n "$m" ]; then USB_ENTRY="$m"; echo "Matched USB boot entry by device token '${tok}'."; break; fi
686689
done
687690
fi
688691
689692
# Strategy 3: match the firmware's removable USB entry by "USB" in its description.
690693
if [ -z "$USB_ENTRY" ]; then
691-
m=$(echo "$EFI_OUT" | grep -E '^Boot[0-9A-Fa-f]{4}' | grep -iE 'usb' | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//')
694+
m=$(echo "$EFI_OUT" | grep -E '^Boot[0-9A-Fa-f]{4}' | grep -iE 'usb' | grep -oE '^Boot[0-9A-Fa-f]{4}' | head -1 | sed 's/^Boot//' || true)
692695
if [ -n "$m" ]; then USB_ENTRY="$m"; echo "Matched USB boot entry by 'USB' description."; fi
693696
fi
694697

0 commit comments

Comments
 (0)