带有 Fastlane 和 Cocoapods 的 GitLab CI 无法正常工作 [英] GitLab CI with Fastlane and Cocoapods not working

查看:41
本文介绍了带有 Fastlane 和 Cocoapods 的 GitLab CI 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让 GitLab CI 与 Fastlane 和 Cocoapods 一起使用.

I can't get GitLab CI to work with Fastlane and Cocoapods.

这是我在 Gitlab-CI 期间收到的错误消息:

Here is the error messages I get during the Gitlab-CI:

[!] You cannot run CocoaPods as root.

GitLab CI 日志截图如下:

Here the screenshot of the GitLab CI Log:

这是我写入 MacOS 终端的 gitlab-runner 注册代码:

Here is my gitlab-runner register code that I write into a MacOS Terminal:

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.到目前为止,一切都很好:)

After the run cmd, any git push will cause the GitLab CI to start a new Pipeline. So far, so good :)

但是几秒钟后,出现上述错误.它与 Cocoapods 有关.

But after a few seconds, the above error occurs. And it has to do with the 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 仍然存在.这里有什么问题??

I tried plenty of other Podfile paths, and even tried to run everything on a docker container. But same thing, the error [!] You cannot run CocoaPods as root remains. What is wrong here ??

这是我的 .gitlab-ci.yml 文件:

Here is my .gitlab-ci.yml file:

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 识别???

Any help appreciated. How do you make the Podfile being recognised by the CI ???

推荐答案

我通过添加 -user 选项解决了我的问题.喜欢

I resolved my problem by adding -user option. Like

sudo gitlab-runner run -user

这篇关于带有 Fastlane 和 Cocoapods 的 GitLab CI 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆