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