Fix usage of gitlab-runner binary as a service in the MacOS VM
We currently need to run gitlab-runner run
instead of gitlab-runner start
in Shared Runner VMs used for onboarding users. When running from the admin
login session but with sudo su -- gitlab-runner
, gitlab-runner start
returns the following error:
bash-3.2$ gitlab-runner start
Runtime platform arch=amd64 os=darwin pid=434 revision=6fbc7474 version=13.1.1
FATAL: Failed to start gitlab-runner: "launchctl" failed: exit status 112, Could not find domain for port (Aqua)
See:
-
https://docs.gitlab.com/runner/install/osx.html#limitations-on-macos
The service will be launched as a LaunchAgent. By using LaunchAgents, the builds will be able to perform UI interactions, making it possible to run and test in the iOS simulator.
-
https://github.com/buildkite/docs/issues/353#issuecomment-543754446
Note: Run gitlab-runner install -d $HOME --syslog
in the context of the gitlab-runner
and ~/Library/LaunchAgents/gitlab-runner.plist
will be generated.
Working setup
After some tests, this is a working setup:
-
Assign a password to
gitlab-runner
user -
Login to
gitlab-runner
account through the UI (SSH will not work) -
Run
gitlab-runner start
:macos-catalina:~ gitlab-runner$ gitlab-runner status Runtime platform arch=amd64 os=darwin pid=1073 revision=4e1f20da version=13.4.0 gitlab-runner: Service is running!
Proposal
- Assign a random password to the
gitlab-runner
account upon creation -
Enable auto-login on the
gitlab-runner
account - Disable all the first-run configuration screens for
gitlab-runner
account, so that the service can start on next reboot.
When the VM is started from this image, it will automatically log in to the gitlab-runner
account, which will ensure that the gitlab-runner
service is started.