Job failed with exit status 1 without any error

I’m trying to create a runner setup script using the GitLab CI pipeline. Here, I registered the executor as shell and planning to run an initial pipeline that set up the runner machines with all the required installations. I need to build flutter APKs using the pipeline.

Everything is working except a command to accept Android licenses using flutter. I’m getting the response which says:

All SDK package licenses accepted

But the job’s status is failed. Not sure what causes this to fail. This command is working in the machine (directly) without any issues.
This is the .gitlab-ci.yml code

runner-machine-configuration: 
  tags: 
    - flutter

  stage: configuration

  script: 
    # Accept Licenses
    - yes | flutter doctor --android-licenses

  rules: 
    - if: $CI_COMMIT_BRANCH == "devops1"
      when: always

This is the error message:

How can I troubleshoot and find the issue? Please help.

Hi @neron_joseph
Runner is dependent on the exit code of the command. If the exit code is other than ‘0’ it is considered as failed.
You can check locally what exit code is returned by that command my_command; echo $?

Hi @balonik, when I run the command from the terminal. I’m getting the exit code as ‘0’. This is the screenshot.

But when I tried the same via GitLab CI, the job failed. Screenshot below:
Screenshot from 2021-06-20 06-35-19

In that case I would look at the next command in the script.

Actually, I have tried creating a separate job with only the above command in order to avoid job failure on other commands. In that case, also, it failed.

The last screenshot that I’ve shared has only this command in that job:

yes | flutter doctor --android-licenses; echo $?

@neron_joseph I am struggling with the same problem on my gitlab runner, did you find any solution for this?

One more thought. GitLab runner is running under a dedicated user gitlab-runner if you are using shell executor. Make sure, that user has the same environment as your user. Or try to run the command under gitlab-runner user and see if it works.

Same here in 2023.
Seems like Gitlab runner doesn’t like yes command for some reason.
As in my case it also used and also runner interpreting result with error code 1, while if i’m doing the same from gitlab-runner user manually, bash shows

$ echo $?
0

Found the solution and explanation here bash - Gitlab runner in docker '$ yes | true' returns with exit 1 - Stack Overflow