Pause uploads if make reports an error but CI still publishes an image. Keep the last known good build. Test in a temporary directory on the runner using the same shell as the job.
Which command succeeded?
In a fresh Bash session, deliberately fail the first command. Both tests assume tee can write. Read the exit status immediately.
(
set +e
set +o pipefail
false | tee build.log
echo $?
set -o pipefail
false | tee build.log
echo $?
)

In this isolated Linux container the default result is 0 because tee succeeded. With pipefail it becomes 1. The final 7 shows why you save the status before printing the log. No firmware was built here.
Return the failure to CI
If live output is optional, redirect directly in the CI script at the source root. Keep your original targets and flags.
make V=s >build.log 2>&1 || {
rc=$?
cat build.log >&2
exit "$rc"
}
For live output, enable pipefail in the same Bash step, check the pipeline status and exit on failure. Make normally runs separate recipe lines in separate shells. Check for a leading minus sign and any CI setting that tolerates failures.
set -o pipefail
make V=s 2>&1 | tee build.log || exit "$?"
Prove a stale image cannot be uploaded
Replace the upload with a printed marker. Substitute false for the build command. The job must fail without printing the marker. Restore the command and use an empty output directory. Resume uploads only when the marker appears on success and the new image matches the device, package manifest and checksum.
Moving OpenWrt from x86 to ARM: check the ABI, packages and kernel modules
Comments