GitLab Runner macOS 作业失败,无法调试

Ric*_*hiy 2 gitlab gitlab-ci-runner

我正在使用单个 macOS GitLab 运行程序来执行 iOS 作业。runner 已成功与 GitLab 配对并接收作业,但是,作业立即失败并且 runner 向 GitLab 报告。

通过查看运行器日志,我无法追踪问题,即使在--debug模式下运行 GitLab Runner 也是如此。

问题:

  1. 这个问题可能与什么有关?
  2. 如何收集更多有关它的信息?

GitLab 网页界面上的工作报告:

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
Run Code Online (Sandbox Code Playgroud)

gitlab-runner --debug run命令的输出:

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
Run Code Online (Sandbox Code Playgroud)

gitlab-ci.yml我正在使用的文件:

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
Run Code Online (Sandbox Code Playgroud)

fur*_*ury 7

检查您的 ~/.bash_profile 和 ~/.profile 是否有可能默默失败的行。

GitLab Runnerset -eo pipefail在它的 restore_cache 阶段的顶部执行 a导致失败的命令(包括您的配置文件中的任何一个)发出管道错误,使其在该阶段静默退出。

就我而言:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Run Code Online (Sandbox Code Playgroud)

一旦我注释掉这一行(我在两个文件中都有它),我的 Mac 的 GitLab 运行器就能够运行

这是一个棘手的问题,因为这不会导致我的正常终端表现出任何错误行为。我必须通过调试运行程序并明确测试脚本来解决这个问题,直到我找到失败的那个


nox*_*oxo 3

它似乎与 RVM 相关,并且它添加到 .bash_profile 和 .profile 文件中的脚本。

  • 注释掉 ~/.bash_profile 和 ~/.profile 文件中 Fury 提到的行
  • 添加source "$HOME/.rvm/scripts/rvm".gitlab-ci.yml,以before_script在管道运行时使用RVM设置的Ruby版本