Setting up a remote Mac machine for Gitlab CI

There's a 1000 posts on this topic online and not one of them explains that you need to modify the location of the launching plist for this runner to work on sudden restarts.

Except maybe this post from symflower

Even that has it at the end so you hardly ever find it on first search unless you are looking for it and hence, this post.

This is a reference post and may or may not be helpful or detailed enough for a beginner, if you do need help with it, you can just contact me and I'll try to help you out.

Let's get done with the basic steps. These are all to be done on the remote screen / vnc app and not via ssh.

  1. Start the Mac instance, obviously.
  2. Setup XCode,Android Studio, whatever the hell you feel like you need for your builds to work.
  3. Next, up, by the way, if you didn't already know, you can actually install android studio using brew brew install --cask android-studio
  4. Use brew to install gitlab-runner
  5. Register the runner, can find steps to this on the first result of google for "registering self hosted gitlab runner"
  6. Start the service brew services start gitlab-runner

Now, we get into the part where I can start things with SSH.

Now connect via SSH and copy paste the below xml to /Library/LaunchDaemons/homebrew.mxcl.gitlab-runner.plist

and you can now restart the machine via ssh and even if the user isn't logged in via GUI, the service should still start.

Replace #user# with the username of the CI user, preferably a non-root user.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">