fix(ci): handle `tee` trying to write to a closed pipe (#7580)
Use `trap '' PIPE` as a command in the pipeline might exit early and we want the script to continue executing, as using `grep --max-count=1` might exit after finding the first match, causing a broken pipe error with `tee`. This is being combined with `set -o pipefail` to have strict error handling and we want the script to fail if any command in the pipeline fails.
This commit is contained in:
parent
dbdb4be429
commit
2b0b2a4292
|
|
@ -592,6 +592,9 @@ jobs:
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
--ssh-flag="-o ConnectTimeout=5" \
|
||||||
--command=' \
|
--command=' \
|
||||||
set -e;
|
set -e;
|
||||||
|
set -o pipefail;
|
||||||
|
trap '' PIPE;
|
||||||
|
|
||||||
sudo docker logs \
|
sudo docker logs \
|
||||||
--tail all \
|
--tail all \
|
||||||
--follow \
|
--follow \
|
||||||
|
|
@ -599,11 +602,13 @@ jobs:
|
||||||
tee --output-error=exit /dev/stderr | \
|
tee --output-error=exit /dev/stderr | \
|
||||||
grep --max-count=1 --extended-regexp --color=always \
|
grep --max-count=1 --extended-regexp --color=always \
|
||||||
"test result: .*ok.* [1-9][0-9]* passed.*finished in"; \
|
"test result: .*ok.* [1-9][0-9]* passed.*finished in"; \
|
||||||
|
|
||||||
EXIT_STATUS=$( \
|
EXIT_STATUS=$( \
|
||||||
sudo docker wait ${{ inputs.test_id }} || \
|
sudo docker wait ${{ inputs.test_id }} || \
|
||||||
sudo docker inspect --format "{{.State.ExitCode}}" ${{ inputs.test_id }} || \
|
sudo docker inspect --format "{{.State.ExitCode}}" ${{ inputs.test_id }} || \
|
||||||
echo "missing container, or missing exit status for container" \
|
echo "missing container, or missing exit status for container" \
|
||||||
); \
|
); \
|
||||||
|
|
||||||
echo "sudo docker exit status: $EXIT_STATUS"; \
|
echo "sudo docker exit status: $EXIT_STATUS"; \
|
||||||
exit "$EXIT_STATUS" \
|
exit "$EXIT_STATUS" \
|
||||||
'
|
'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue