当我在 circleCI 上使用 FastLane 构建 MacOS 项目时,遇到了以下错误。我可以在本地使用 bundle exec fastlane test
因此,这个问题似乎与CircleCI环境有关,但我不知道如何追踪它。当我ssh进入CircleCI时,我能够在命令行上重现它。
以下是错误信息。
bundler: failed to load command: fastlane (usrlocalbinfastlane)NoMethodError: [!]undefined method `each' for nil:NilClass LibraryRubyGems2.6.0gemsfastlan-2.149.1scanlibscanrunner.rb:172:in `copy_simulator_logs' LibraryRubyGems2.6.0gemsfastlan-2. 149.1scanlibscanrunner.rb:108:in `handle_results' LibraryRubyGems2.6.0gemsfastlan-2.149.1scanlibscanrunner.rb:22:in `run' LibraryRubyGems2.6.0gemsfastlan-2. 149.1scanlibscanmanager.rb:23:in `work' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlaneactionsrun_tests.rb:16:in `run' LibraryRubyGems2.6.0gemsfastlan-2. 149.1fastlanelibfastlanerunner.rb:261:in `block (2 levels) in execute_action' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlaneactions_helper. rb:50:in `execute_action' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlanerunner.rb:253:in `block in execute_action' LibraryRubyGems2.6.0gemsfastlan-2. 149.1fastlanelibfastlanerunner.rb:227:in `chdir' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlanerunner.rb:227:in `execute_action' LibraryRubyGems2. 6.0gemsfastlan-2.149.1fastlanelibfastlanerunner.rb:157:in `trigger_action_by_name' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlanefast_file. rb:159:in `method_missing' Fastfile:26:in `block (2 levels) in parsing_binding' LibraryRubyGems2.6.0gemsfastlan-2.149.1fastlanelibfastlanelane.rb:33:in `call' ------------------------------------------。
我的Fastfile是这样的
default_platform :mac
platform :mac do
before_all do
setup_circle_ci
end
desc "Runs all the tests"
lane :test do
scan(skip_testing: "ChronosUITests")
end
desc "Ad-hoc build"
lane :adhoc do
match(type: "adhoc")
gym(export_method: "ad-hoc")
end
end
我的 circleci 配置是这样的
# .circleci/config.yml
version: 2.1
jobs:
build-and-test:
macos:
xcode: 11.5.0
environment:
FL_OUTPUT_DIR: output
FASTLANE_LANE: test
steps:
- checkout
# https://support.circleci.com/hc/en-us/articles/360044709573-Swift-Package-Manager-fails-to-clone-from-private-Git-repositories
- run: rm ~/.ssh/id_rsa
- run: for ip in $(dig @8.8.8.8 bitbucket.org +short); do ssh-keyscan bitbucket.org,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true
- run: for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true
# -------
- run: bundle install
- run:
name: Fastlane
command: bundle exec fastlane $FASTLANE_LANE
- store_artifacts:
path: output
- store_test_results:
path: output/scan
adhoc:
macos:
xcode: 11.5.0
environment:
FL_OUTPUT_DIR: output
FASTLANE_LANE: adhoc
steps:
- checkout
# https://support.circleci.com/hc/en-us/articles/360044709573-Swift-Package-Manager-fails-to-clone-from-private-Git-repositories
- run: rm ~/.ssh/id_rsa
- run: for ip in $(dig @8.8.8.8 bitbucket.org +short); do ssh-keyscan bitbucket.org,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true
- run: for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true
# -----
- run: bundle install
- run:
name: Fastlane
command: bundle exec fastlane $FASTLANE_LANE
- store_artifacts:
path: output
workflows:
build-test-adhoc:
jobs:
- build-and-test
- adhoc:
filters:
branches:
only: development
requires:
- build-and-test