Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab runner in docker '$ yes | true' returns with exit 1

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

like image 827
Diolor Avatar asked Mar 06 '23 14:03

Diolor


2 Answers

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

like image 57
Charles Duffy Avatar answered Mar 10 '23 10:03

Charles Duffy


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.

like image 21
mncl Avatar answered Mar 10 '23 11:03

mncl