【问题标题】:Gitlab CI Pipeline fails because of ruby issue (Ruby installed)由于 ruby​​ 问题,Gitlab CI Pipeline 失败(安装了 Ruby)
【发布时间】:2021-12-31 02:45:19
【问题描述】:

我正在尝试在 Gitlab 上设置 CI。我有问题。看起来跑步者运行良好,但每次我尝试运行管道时都会失败并出现以下错误:

Running with gitlab-runner 14.4.0 (4b9e985a)
  on local-runner g_SbFiLZ
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on GU33...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Users/xxx/GitLab-Runner/builds/g_SbFiLZ/0/xxx/xxx/.git/
Checking out f4fb6ec9 as main...
git-lfs/2.11.0 (GitHub; windows amd64; go 1.14.2; git 48b28d97)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ gem install bundler
gem : The term 'gem' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script461193448\script.ps1:225 char:1
+ gem install bundler
+ ~~~
    + CategoryInfo          : ObjectNotFound: (gem:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1

我已经正确安装和设置了 Ruby。我可以在本地运行 gem 命令。 Runner 也是在本地设置的,所以我真的不明白这个问题。这是我的 gitlab-ci.yml :

stages:
  - prepare
  - build
  - test
  - ui-test

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

.setup_bundler: &setup_bundler |
  gem install bundler
  bundle config
  bundle install

.setup: &setup
  - *setup_bundler

prepare_project:
  stage: prepare
  script:
    *setup
  cache:
    key:
      files:
        - Gemfile.lock
    paths:
      - vendor
  artifacts:
    name: "Bundle_${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}_${CI_BUILD_ID}"
    expire_in: 1 day
    paths:
      - vendor
    when: always
  when: on_success
  tags:
    - android

build:
  stage: build
  script:
    - bundle exec fastlane build
  dependencies:
    - prepare_project
  tags:
    - android

test:
  stage: test
  script:
    - bundle exec fastlane tests
  dependencies:
    - prepare_project
  tags:
    - android

ui-test:
  stage: ui-test
  script:
    - bundle exec fastlane ui_tests
  dependencies:
    - prepare_project
  tags:
    - android

有什么想法吗?

【问题讨论】:

    标签: android gitlab continuous-integration


    【解决方案1】:

    很可能当您运行gem 进行调试时,您使用的用户与gitlab-runner 不同,这是默认的gitlab-runner 用户。检查您的 gitlab-runner 用户的 PATH 设置,并确保 gem 在路径上。

    【讨论】:

    • 你的意思是在我的环境变量中检查 PATH ?我在那里添加了 Ruby - 效果很好。
    • 是的,特别是在您的gitlab-runner 用户的环境变量中(这是运行默认使用的用户,如果您指定了不同的用户,也为该用户设置PATH)。听起来你已经让它工作了,这很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多