Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab Runner macOS job fails, unable to debug

I'm using single macOS GitLab runner to execute iOS jobs. The runner has been successfully paired with the GitLab and receives jobs, however, the job fails immediately and the runner reports back to the GitLab.

By looking at the runner logs, I'm unable to trace the issue, even when running the GitLab Runner in the --debug mode.

Questions:

  1. What the issue could be related to?
  2. How to gather more information about it?

Job report on the GitLab web interface:

Running with gitlab-runner 11.7.0 (8cc638ff)
  on iMac 8cc638ff
Using Shell executor...
Running on name-iMac.local...
Fetching changes...
ERROR: Job failed: exit status 1

Output of the gitlab-runner --debug run command:

Checking for jobs... received                       job=216 repo_url=https://gitlab.local/software/ios.git runner=00000000
Failed to requeue the runner:                       builds=1 runner=00000000
Running with gitlab-runner 11.7.0 (8bb608ff)        job=216 project=34 runner=00000000
  on iMac 00000000                                  job=216 project=34 runner=00000000
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=216 project=34 runner=00000000
Using Shell executor...                             job=216 project=34 runner=00000000
Waiting for signals...                              job=216 project=34 runner=00000000
Executing build stage                               build_stage=prepare_script job=216 project=34 runner=00000000
Executing build stage                               build_stage=get_sources job=216 project=34 runner=00000000
Executing build stage                               build_stage=upload_artifacts_on_failure job=216 project=34 runner=00000000
WARNING: Job failed: exit status 1                  duration=538.074ms job=216 project=34 runner=00000000

The gitlab-ci.yml file I'm using:

stages:
  #- unit_tests
  - test_flight

variables:
  LC_ALL: "en_US.UTF-8"
  LANG: "en_US.UTF-8"

before_script:
  - gem install bundler
  - bundle install

# unit_tests:
#   dependencies: []
#   stage: unit_tests
#   artifacts:
#     paths:
#       - fastlane/screenshots
#       - fastlane/logs
#   script:
#     - fastlane tests
#   tags:
#     - ios

test_flight_build:
  dependencies: []
  stage: test_flight
  artifacts:
    paths:
      - fastlane/screenshots
      - fastlane/logs
  script:
    - fastlane beta
  tags:
    - ios
  only:
     - /^release-.*$/
     - master
     - testflight
like image 985
Richard Topchii Avatar asked Dec 17 '22 18:12

Richard Topchii


1 Answers

Check your ~/.bash_profile and ~/.profile for lines that may be silently failing.

GitLab Runner does a set -eo pipefail at the top of its restore_cache stage which causes a failing command (including any of those in your profile) to issue a pipe error which makes it silently exit at that stage.

In my case:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Once I commented this line out (I had it in both files), my Mac's GitLab runner was able to run

This was a tricky one, because this did not cause my normal terminals to exhibit any erroneous behaviors. I had to figure it out by debugging the runner and explicitly testing the scripts until I found the one that failed

like image 157
fury Avatar answered Dec 21 '22 18:12

fury