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

查看:217
本文介绍了带有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启动新的管道.到目前为止,一切都很好:)

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

但是几秒钟后,发生上述错误.这与可可足有关.

But after a few seconds, the above error occurs. And it has to do with the Cocoapods.

如何在CI期间使Gitlab(和/或Fastlane)识别Podfile?

这是我的Fastfile:

Here is my 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

我尝试了许多其他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

任何帮助表示赞赏.您如何使CI识别Podfile?

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

推荐答案

我终于找到了解决方案:

I finally found the solution:

也不允许您的gitlab-runner register具有sudo.

由于某些原因,有很多教程显示的内容不同(即使用sudo),例如

For some reason there are many tutorials out there that show differently (i.e. with sudo) - such as this video or others...

无论如何,正如 @Scriptable 所指出的那样,在Mac上,您绝对需要保留sudo!

Anyway, as @Scriptable pointed out, on a Mac you absolutely need to leave sudo out !

这里是我找到的最好的教程关于如何在iOS项目中使用Gitlab CI.

Here is the best tutorial I have found on how to Gitlab CI an iOS project.

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

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