Jenkins iOS fastlane build:找不到'bundler'

jjjwad0x  于 2023-04-05  发布在  Jenkins
关注(0)|答案(1)|浏览(180)

我尝试将Jenkins与fastlane结合使用。执行构建的mac是jenkins master的从机。master安装在windows 10系统上。
当尝试使用Jenkins构建iOS Build并使用bundle installbundle exec fastlane beta时,我总是得到错误:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs':Could not find 'bundler'(〉= 0.a)among 253 total gem(s)(Gem::LoadError)

from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle:25:in `<main>'
from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `<main>'

当我在mac本身的终端中执行命令bundle install时,命令的工作方式与预期的一样。
我的Jenkins命令看起来像这样:

export PATH="/usr/local/bin:$PATH"
export PATH="$HOME/.fastlane/bin:$PATH"
export PATH="$HOME/.rvm/bin:$PATH"
export PATH="$HOME/.rvm/bin/rvm:$PATH"
export PATH="$HOME/.rvm/gems/ruby-2.5.0:$PATH"
export PATH="$HOME/.rvm/gems/ruby-2.5.0/bin:$PATH"

bundle install
bundle exec fastlane beta

我也尝试了命令的完整路径:$HOME/.rvm/gems/ruby-2.5.0/bin/bundle install,但这会导致相同的错误。
如果我尝试在没有bundle命令的情况下运行fastlane,那么Could not find 'fastlane'也会出现同样的错误。所以我认为这与路径和Jenkins没有找到/获取正确文件夹的正确路径有关。但我不知道安装程序中的错误隐藏在哪里。
其他信息:
echo $PATH返回:

/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0@global/bin:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/usr/local/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/appfiff/Development/android-sdk-macosx 2/platform-tools:/Users/appfiff/Development/android-sdk-macosx 2/tools:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/u3d:/usr/local/git/bin:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/u3d

Jenkins命令的完整输出是:

+ export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ export PATH=/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ export PATH=/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ export PATH=/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ export PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/apppfiff/.rvm/bin
+ export PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
+ /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle install
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0.a) among 253 total gem(s) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle:25:in `<main>'
    from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
    from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `<main>'

.

$ which bundle
/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle

$ which ruby
/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/ruby

$ gem list bundler
*** LOCAL GEMS ***

bundler (1.16.3)
bundler-unload (1.0.2)
rubygems-bundler (1.4.4)

我的Gemfile:

source "https://rubygems.org"

gem "fastlane"

我的Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    CFPropertyList (3.0.0)
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    atomos (0.1.2)
    babosa (1.0.2)
    claide (1.0.2)
    colored (1.2)
    colored2 (3.1.2)
    commander-fastlane (4.4.6)
      highline (~> 1.7.2)
    declarative (0.0.10)
    declarative-option (0.1.0)
    domain_name (0.5.20180417)
      unf (>= 0.0.5, < 1.0.0)
    dotenv (2.5.0)
    emoji_regex (0.1.1)
    excon (0.62.0)
    faraday (0.15.2)
      multipart-post (>= 1.2, < 3)
    faraday-cookie_jar (0.0.6)
      faraday (>= 0.7.4)
      http-cookie (~> 1.0.0)
    faraday_middleware (0.12.2)
      faraday (>= 0.7.4, < 1.0)
    fastimage (2.1.3)
    fastlane (2.100.0)
      CFPropertyList (>= 2.3, < 4.0.0)
      addressable (>= 2.3, < 3.0.0)
      babosa (>= 1.0.2, < 2.0.0)
      bundler (>= 1.12.0, < 2.0.0)
      colored
      commander-fastlane (>= 4.4.6, < 5.0.0)
      dotenv (>= 2.1.1, < 3.0.0)
      emoji_regex (~> 0.1)
      excon (>= 0.45.0, < 1.0.0)
      faraday (~> 0.9)
      faraday-cookie_jar (~> 0.0.6)
      faraday_middleware (~> 0.9)
      fastimage (>= 2.1.0, < 3.0.0)
      gh_inspector (>= 1.1.2, < 2.0.0)
      google-api-client (>= 0.21.2, < 0.22.0)
      highline (>= 1.7.2, < 2.0.0)
      json (< 3.0.0)
      mini_magick (~> 4.5.1)
      multi_json
      multi_xml (~> 0.5)
      multipart-post (~> 2.0.0)
      plist (>= 3.1.0, < 4.0.0)
      public_suffix (~> 2.0.0)
      rubyzip (>= 1.2.1, < 2.0.0)
      security (= 0.1.3)
      simctl (~> 1.6.3)
      slack-notifier (>= 2.0.0, < 3.0.0)
      terminal-notifier (>= 1.6.2, < 2.0.0)
      terminal-table (>= 1.4.5, < 2.0.0)
      tty-screen (>= 0.6.3, < 1.0.0)
      tty-spinner (>= 0.8.0, < 1.0.0)
      word_wrap (~> 1.0.0)
      xcodeproj (>= 1.5.7, < 2.0.0)
      xcpretty (~> 0.2.8)
      xcpretty-travis-formatter (>= 0.0.3)
    gh_inspector (1.1.3)
    google-api-client (0.21.2)
      addressable (~> 2.5, >= 2.5.1)
      googleauth (>= 0.5, < 0.7.0)
      httpclient (>= 2.8.1, < 3.0)
      mime-types (~> 3.0)
      representable (~> 3.0)
      retriable (>= 2.0, < 4.0)
    googleauth (0.6.2)
      faraday (~> 0.12)
      jwt (>= 1.4, < 3.0)
      logging (~> 2.0)
      memoist (~> 0.12)
      multi_json (~> 1.11)
      os (~> 0.9)
      signet (~> 0.7)
    highline (1.7.10)
    http-cookie (1.0.3)
      domain_name (~> 0.5)
    httpclient (2.8.3)
    json (2.1.0)
    jwt (2.1.0)
    little-plugger (1.1.4)
    logging (2.2.2)
      little-plugger (~> 1.1)
      multi_json (~> 1.10)
    memoist (0.16.0)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mini_magick (4.5.1)
    multi_json (1.13.1)
    multi_xml (0.6.0)
    multipart-post (2.0.0)
    nanaimo (0.2.6)
    naturally (2.2.0)
    os (0.9.6)
    plist (3.4.0)
    public_suffix (2.0.5)
    representable (3.0.4)
      declarative (< 0.1.0)
      declarative-option (< 0.2.0)
      uber (< 0.2.0)
    retriable (3.1.2)
    rouge (2.0.7)
    rubyzip (1.2.1)
    security (0.1.3)
    signet (0.8.1)
      addressable (~> 2.3)
      faraday (~> 0.9)
      jwt (>= 1.5, < 3.0)
      multi_json (~> 1.10)
    simctl (1.6.5)
      CFPropertyList
      naturally
    slack-notifier (2.3.2)
    terminal-notifier (1.8.0)
    terminal-table (1.8.0)
      unicode-display_width (~> 1.1, >= 1.1.1)
    tty-cursor (0.6.0)
    tty-screen (0.6.5)
    tty-spinner (0.8.0)
      tty-cursor (>= 0.5.0)
    uber (0.1.0)
    unf (0.1.4)
      unf_ext
    unf_ext (0.0.7.5)
    unicode-display_width (1.4.0)
    word_wrap (1.0.0)
    xcodeproj (1.5.9)
      CFPropertyList (>= 2.3.3, < 4.0)
      atomos (~> 0.1.2)
      claide (>= 1.0.2, < 2.0)
      colored2 (~> 3.1)
      nanaimo (~> 0.2.5)
    xcpretty (0.2.8)
      rouge (~> 2.0.7)
    xcpretty-travis-formatter (1.0.0)
      xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
  ruby

DEPENDENCIES
  fastlane

BUNDLED WITH
   1.16.3

有效措施:

  • 直接在slave mac上调用终端中的bundle installbundle exec fastlane beta
  • Jenkins中的其他构建步骤

我已经试过了:

我想知道的是:

  • 我的设置中的错误在哪里?我有一种感觉,这是一些简单的东西。
  • 我需要做什么,我可以使用Jenkins与fastlane。
zbwhf8kr

zbwhf8kr1#

尝试将源代码设置为rvm,我有一个这样的设置:

export GEM_HOME=\$HOME/.rvm/gems/ruby-2.5.0
export GEM_PATH=\$HOME/.rvm/gems/ruby-2.5.0:\$HOME/.rvm/gems/ruby-2.5.0@global
LANG=en_US.UTF-8
source "\$HOME/.rvm/scripts/rvm"
bundle update && bundle install
bundle exec fastlane $cmd

看起来你在Jenkins JVM中使用了错误的ruby版本:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0...

在调用bundle ...之前,您可能需要使用rvm use 2.5.0设置正确的版本
Jenkins的主要问题是,它运行在一个不同的环境中,然后你的终端(一般是你的Mac),因为它工作在JVM中。由于这个设置,你需要像我一样调用你的setup,然后再调用你的Bundler(或任何ruby gem)。

相关问题