急需帮助:
已经问过gitlab-runner register
为“ shell”的情况,我尝试在这里以gitlab-runner register
为“ docker”问一个非常相似的问题。
自3天以来,我一直尝试运行Gitlab CI(使用docker,fastlane-全部用于具有Cocoapods依赖项的iOS应用)。
这是GitLab CI吐出的错误消息:
我执行了以下步骤:
安装快速通道(link to fastlane page)
创建一个GitLab项目并上传您的项目存储库(link to GitLab)
在MacOS following these steps...
安装Docker(用于台式机),registering here and downloading the app
注册gitlab-runner(即打开终端并输入以下内容): (您的令牌可以在GitLab->设置-> 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映像(通过在终端中键入以下内容:)
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
所有这些之后,任何git push到您的GitLab项目存储库中,都会自动启动管道。
我还尝试使用本地shell(而不是docker)-但as documented here均未成功。
无论我尝试什么,我总是会收到相同的错误消息:
[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
答案 0 :(得分:0)
我终于找到了解决方法:
您的gitlab-runner register
不允许有sudo
。
由于某种原因,有很多教程显示的内容不同(即使用sudo),例如this video或其他...
无论如何,在Mac上,您绝对需要保留sudo并绝对注册为GitLab的“ shell”执行程序(即不是“ docker”)
Here is the best tutorial I have found,介绍如何Gitlab CI一个iOS项目。