docker - 带有 Docker、Fastlane 和 Cocoapods 的 GitLab CI 无法正常工作
问题描述
急需帮助:
已经用gitlab-runner register
“shell”询问了这个案例,我尝试在这里用gitlab-runner register
“docker”提出一个非常相似的问题。
从 3 天开始,我尝试让 Gitlab CI 运行(使用 docker、fastlane - 全部用于具有 Cocoapods 依赖项的 iOS 应用程序)。
这是 GitLab CI 吐出的错误消息:
我做了以下步骤:
安装 fastlane(链接到 fastlane 页面)
创建一个 GitLab 项目并上传您的项目存储库(指向 GitLab 的链接)
按照以下步骤在 MacOS 上安装 gitlab-runner ...
安装 Docker(桌面版),在此处注册并下载应用程序
注册 gitlab-runner(即打开终端并输入以下内容):(您的 Token 可以在 GitLab-->Settings-->CI/CD 下找到)
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "TOKENABCDEFG" \
--description "MyApp runner with ruby-2.6" \
--tag-list ios \
--executor "docker" \
--docker-image ruby:2.6
在 Mac 上启动 docker 应用程序
运行 docker image (通过在终端中输入以下内容:)
docker run -d --name gitlab-runner --restart always \
-v /Users/Shared/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
毕竟,任何对 GitLab 项目 repo 的 git push 都会自动启动 Pipeline。
我还尝试使用本地 shell(而不是 docker) - 但也没有成功,如此处所述。
无论我尝试什么,我总是会收到相同的错误消息:
[08:48:04]: Driving the lane 'ios tests'
[08:48:04]: -----------------------
[08:48:04]: --- Step: cocoapods ---
[08:48:04]: -----------------------
[08:48:04]: Using deprecated option: '--clean' (true)
[08:48:04]: $ cd '.' && bundle exec pod install
[08:48:04]: ▸ WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
[08:48:04]: ▸ Consider adding the following to ~/.profile:
[08:48:04]: ▸ export LANG=en_US.UTF-8
[08:48:04]: ▸
[08:48:04]: ▸ bundler: failed to load command: pod (/usr/local/bundle/bin/pod)
[08:48:04]: ▸ CLAide::Help: [!] You cannot run CocoaPods as root.
这是我的.gitlab-ci.yml
文件:
stages:
- unit_tests
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:
- bundle exec fastlane tests
tags:
- ios
这里是 Fastfile:
update_fastlane
default_platform(:ios)
platform :ios do
def install_pods
cocoapods(
clean: true,
podfile: "./Podfile",
try_repo_update_on_error: true
)
end
lane :tests do
install_pods()
gym(configuration: "Release",
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
clean: true,
output_name: "MyApp.ipa")
# increment_build_number
scan(workspace: "MyApp.xcworkspace",
devices: ["iPhone SE", "iPhone XS"],
scheme: "MyAppTests")
end
解决方案
推荐阅读
- python - 在熊猫中将格式不一致的字符串日期转换为日期时间
- javascript - 如何对对象中的过滤数组进行排序?
- google-bigquery - 为上个月创建具有真/假的列
- javascript - 为什么在函数 javascript 中一切都返回 true?
- python - 使用 IF 条件和 s.str.startswith 时出错
- python - 需要帮助将 python 脚本翻译成 vba
- javascript - 格式化对象并将对象添加到数组的函数无法正常运行
- javascript - 如何通过引用在 2 个 javascript 文件之间传递数组
- recursion - 修改后的函数在没有递归的情况下无法按预期工作
- jquery - 使用 chart.js 在水平条形图中模糊图表、X 和 Y 轴标签