【发布时间】:2019-03-27 15:46:15
【问题描述】:
我无法让 GitLab CI 与 Fastlane 和 Cocoapods 一起使用。
这是我在 Gitlab-CI 期间收到的错误消息:
[!] You cannot run CocoaPods as root.
GitLab CI 日志截图如下:
这是我写入 MacOS 终端的 gitlab-runner 注册代码:
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "ABCDEFG21sadfSAEGEAERE" \
--description "MyApp runner with shell" \
--tag-list ios \
--executor "shell"
然后我在终端中输入:
sudo gitlab-runner start
还有……
sudo gitlab-runner run
在run cmd 之后,任何 git push 都会导致 GitLab CI 启动一个新的 Pipeline。到目前为止,一切都很好:)
但是几秒钟后,出现上述错误。它与 Cocoapods 有关。
如何让 Gitlab(和/或 Fastlane)在 CI 期间识别 Podfile?
这是我的快速文件:
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
我尝试了很多其他 Podfile 路径,甚至尝试在 docker 容器上运行所有内容。但同样的事情,错误[!] 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
任何帮助表示赞赏。如何让 Podfile 被 CI 识别???
【问题讨论】:
-
"您不能以 root 身份运行 CocoaPods。" - 不要以 root 身份运行,即不要使用
sudo -
感谢您的解释。您能否指定不使用
sudo的位置。你的意思是改用gitlab-runner start和gitlab-runner run吗?gitlab-runner run(没有 sudo)的问题在于,在这种情况下,CI-Pipeline 出于某种原因永远不会启动。你能举例说明你的意思吗? -
您不需要以管理员用户身份运行任何部分。作为正确配置/受限制的用户犯了一个错误,它可能没那么糟糕。以 root 身份执行此操作,可能会对您的机器/服务器造成严重损坏。在没有 sudo 的情况下运行所有内容,如果它抱怨,请调查它为什么需要它。您可能只需要更改某些文件/文件夹的所有权/访问权限
-
如果我使用
gitlab-runner run而不是sudo gitlab-runner run,那么我最终会在我的Gitlab-CI 设置中看到New runner: Has not connected yet消息。跑步者似乎没有启动或连接(我的终端只显示并冻结Listen address not defined)。我怎样才能让 gitlab-runner 在没有 sudo 的情况下运行??????需要设置哪些权限以及在哪里设置? (我在 MacOS 上)
标签: continuous-integration realm gitlab cocoapods fastlane