GitLab CI with Fastlane and Cocoapods not working

感情迁移 提交于 2019-12-02 21:47:52

问题


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

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

[!] You cannot run CocoaPods as root.

Here the screenshot of the GitLab CI Log:

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"

After that I type inside the terminal:

sudo gitlab-runner start

and...

sudo gitlab-runner run

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.

How can you make Gitlab (and/or Fastlane) to recognise the Podfile during CI ??

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

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

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

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


回答1:


I finally found the solution:

Also your gitlab-runner register is not allowed to have sudo.

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

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

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



来源:https://stackoverflow.com/questions/55381303/gitlab-ci-with-fastlane-and-cocoapods-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!