Running this command inside a .gitlab-ci.yml:
task:
script:
- yes | true
- yes | someOtherCommandWhichNeedsYOrN
Returns:
$ yes | true
ERROR: Job failed: exit status 1
Any clues, ideas why this happens or how to debug this?
Setup: Gitlab runner in a docker
If running with set -o pipefail
, a failure at any stage in a shell pipeline will cause the entire pipeline to be considered failed. When yes
tries to write to stdout but the program whose stdin that stdout is connected to is not reading, this will cause an EPIPE
signal -- thus, an expected failure message, which the shell will usually ignore (in favor of treating only the last component of a pipeline as important for purposes of that pipeline's exit status).
Turn this off for the remainder of your current script with set +o pipefail
Explicitly ignore a single failure: { yes || :; } | true
Can't comment yet.
I would extract the script in to a file and run that file from the pipeline with some debug stuff in it and see if you can reproduce it.
Make sure you make it to to, and not past, the line in question.
I try the following to get some more info maybe?
( set -x ; yes | true ; echo status: "${PIPESTATUS[@]}" )
See if you have some weird chars in the file or some weird modes set.
Make sure you are in the right shell, true can be built in so worth checking.
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With