Gitlab Runner jobs fails with exit code 1 on Ubuntu 20.04

Gitlab Runner jobs fails with exit code 1 on Ubuntu 20.04

I’m trying to setup automatic gitlab builds for Unity editor using a custom runner. I had it working on the shared runners and trying to adapt it to a shell executor (I don’t want to use docker because it’s really slow for this purpose).

My gitlab-runner fails with exit code 1 when launching my CI and for the life of me, I can’t understand why. I’ve read here and there that you should unset cd because of rvm (which I haven’t installed as far as I’m aware), I did, didn’t work, the official troubleshooting guide says you should remove dotfiles from gitlab-runner user but there are none.

Here is my .gitlab.ci.yml file

stages:
  - build_and_test
  - deploy

# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page:
# settings > CI/CD > Variables instead
variables:
  BUILD_NAME: TestCI
  UNITY_VERSION: "2020.3.1f1"
  UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree.


.unity_before_script: &unity_before_script
  before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh

.cache: &cache
  cache:
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
paths:
  - $UNITY_DIR/Library/

.test: &test
  stage: build_and_test
  <<: *unity_before_script
  <<: *cache
  script:
- chmod +x ./ci/test.sh && ./ci/test.sh
  artifacts:
when: always
expire_in: 2 weeks
  # https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
  # you may need to remove or replace these to fit your need if you are using your own runners
  tags:
- unity
  coverage: /<Linecoverage>(.*?)</Linecoverage>/

test-playmode:
  <<: *test
  variables:
TEST_PLATFORM: playmode

test-editmode:
  <<: *test
  variables:
TEST_PLATFORM: editmode

.build: &build
  stage: build_and_test
  <<: *unity_before_script
  <<: *cache
  script:
- chmod +x ./ci/build.sh && ./ci/build.sh
  artifacts:
paths:
  - $UNITY_DIR/Builds/
  # https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
  # you may need to remove or replace these to fit your need if you are using your own runners
  tags:
- unity

build-StandaloneLinux64:
  <<: *build
  variables:
BUILD_TARGET: StandaloneLinux64

build-StandaloneOSX:
  <<: *build
  variables:
BUILD_TARGET: StandaloneOSX

build-StandaloneWindows64:
  <<: *build
  variables:
BUILD_TARGET: StandaloneWindows64

pages:
  stage: deploy
  script:
- docfx docfx_project/docfx.json
- mv docfx_project/_site public
  artifacts:
paths:
  - public
  only:
- master


generate-version:
  stage: deploy
  script:
- unset cd
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- ssh-add <(echo "$GITLAB_SSH_PRIVATE_KEY")
- pip install semver
- chmod +x ./ci/gen-semver
- ./ci/gen-semver
  only:
- master

workflow:
  rules:
- if: $CI_MERGE_REQUEST_ID
  when: never
- if: $CI_COMMIT_TAG
  when: never
- when: always

Here are the logs I get after the failed jobs (same for any job).

Checking for jobs... received                       job=1131332698 repo_url=https://gitlab.com/my-repo runner=<shorttoken>
Failed to requeue the runner:                       builds=1 runner=<shorttoken>
Running with gitlab-runner 11.2.0 (11.2.0)          job=1131332698 project=25210885 runner=<shorttoken>
  on <My-Runner> <shorttoken>                      job=1131332698 project=25210885 runner=<shorttoken>
Shell configuration: environment: []
dockercommand:
- sh
- -c
- "if [ -x /usr/local/bin/bash ]; then\n\texec /usr/local/bin/bash --login\nelif [
  -x /usr/bin/bash ]; then\n\texec /usr/bin/bash --login\nelif [ -x /bin/bash ]; then\n\texec
  /bin/bash --login\nelif [ -x /usr/local/bin/sh ]; then\n\texec /usr/local/bin/sh
  --login\nelif [ -x /usr/bin/sh ]; then\n\texec /usr/bin/sh --login\nelif [ -x /bin/sh
  ]; then\n\texec /bin/sh --login\nelif [ -x /busybox/sh ]; then\n\texec /busybox/sh
  --login\nelse\n\techo shell not found\n\texit 1\nfi\n\n"
command: bash
arguments:
- --login
passfile: false
extension: ""
  job=1131332698 project=25210885 runner=<shorttoken>
Using Shell executor...                             job=1131332698 project=25210885 runner=<shorttoken>
Waiting for signals...                              job=1131332698 project=25210885 runner=<shorttoken>
WARNING: Job failed: exit status 1                  job=1131332698 project=25210885 runner=<shorttoken>

I successfully ran a simple test job once without error. I believe it has to do with the dockercommand that seems to pop out of nowhere (it’s not in any of my ci scripts)

This CI did work

stages:
   - build

test-job:
   stage: build
   script:
      - echo "It works !"

Does anyone know what’s wrong ? Please help, thanks.