contentTags | ||||
---|---|---|---|---|
|
This page describes how to install CircleCI’s machine runner 3 on macOS.
To install machine runners and run jobs, you will need to have root access, and have the following utilities and tools installed on your system:
-
curl (installed by default on macOS)
-
sha256sum (if not pre-installed):
-
brew install coreutils
-
-
The CircleCI CLI if you wish to install runners from the command line
You can install runner on macOS with Homebrew.
-
On the target macOS machine with Homebrew installed, run the following command to add the CircleCI repository:
brew tap circleci-public/circleci
-
Run the following command to install the
circleci-runner
package:NoteYou may see a notification indicating a background item for Circle Internet Services Inc. has been added. brew install circleci-runner
-
Open the runner
config.yaml
file with the text editor of your choice, and modify therunner.name
andapi.auth_token
values.nano $HOME/Library/Preferences/com.circleci.runner/config.yaml
runner: name: "my-macos-runner" working_directory: "/Users/$USER/Library/com.circleci.runner/workdir" cleanup_working_directory: true api: auth_token: "your-auth-token"
Replace
api.auth_token
with the token generated in the steps above, and choose a name for your runner. -
If you are using CircleCI server you will need to provide the URL for your install. You can do this by either setting the
CIRCLECI_RUNNER_API_URL
environment variable:export CIRCLECI_RUNNER_API_URL="your server domain"
Or by adding the URL to
$HOME/Library/Preferences/com.circleci.runner/config.yaml
using text editor of your choice.api: auth_token: "your-auth-token" # On server, set url to the hostname of your server installation. url: https://your.domain.here
Tip
|
If you are migrating an existing configuration from a previous runner installation, you may move the existing launch agent file from its current path to the new path. This will overwrite the default config file installed via brew and replace it with your existing config file. mv /Library/Preferences/com.circleci.runner/launch-agent-config.yaml $HOME/Library/Preferences/com.circleci.runner/config.yaml After copying the file, you may remove the logging block to send logs to the default location for machine runner 3 (specified below): # remove this block from your existing config
logging:
file: /Library/Logs/com.circleci.runner.log |
The binary must be approved to run on your macOS system because the self-hosted runner is not compiled from source during installation. This can be done via the macOS UI by accepting the pop-up asking if you wish to run the binary from the internet, or programmatically.
-
Verify the signature and notarization with this command:
spctl -a -vvv -t install "$(brew --prefix)/bin/circleci-runner"
It should return an output that looks like this:
/opt/homebrew/bin/circleci-runner: accepted source=Notarized Developer ID origin=Developer ID Application: Circle Internet Services Inc.
-
When ready, run the command to accept the notarization. You will need to enter the macOS system password.
sudo xattr -r -d com.apple.quarantine "$(brew --prefix)/bin/circleci-runner"
To start the macOS machine runner 3 for the first time, you will need to bootstrap the service. Depending on whether you are using a GUI or non-GUI session (for example, when remotely tunneling into the machine), the commands to bootstrap the service will differ:
-
For running the agent in a GUI session, you can bootstrap the provided
.plist
file and enable the service by running the following commands:launchctl bootstrap gui/$(id -u) $HOME/Library/LaunchAgents/com.circleci.runner.plist launchctl enable gui/$(id -u)/com.circleci.runner launchctl kickstart -k gui/$(id -u)/com.circleci.runner
-
Finally, you can check the service is running by invoking the following command:
launchctl print gui/$(id -u)/com.circleci.runner
-
When using a non-GUI (or headless) session, the provided
.plist
file should be moved to/Library/LaunchAgents
. This location is for per-user agents configured by the administrator, which allows the service to load after a reboot. Run the following command to do this:sudo mv $HOME/Library/LaunchAgents/com.circleci.runner.plist /Library/LaunchAgents/
-
Now you can bootstrap the
.plist
file and enable the service by running the following commands:launchctl bootstrap user/$(id -u) /Library/LaunchAgents/com.circleci.runner.plist launchctl enable user/$(id -u)/com.circleci.runner launchctl kickstart -k user/$(id -u)/com.circleci.runner
-
Finally, you can check the service is running by invoking the following command:
launchctl print user/$(id -u)/com.circleci.runner
To stop the machine runner service, run the following command to disable the machine runner service, depending on the service target used in the previous step:
launchctl disable gui/$(id -u)/com.circleci.runner
launchctl disable user/$(id -u)/com.circleci.runner
To uninstall machine runner 3 from your macOS device, follow these steps.
-
Stop the machine runner service by using the following command to disable it, depending on the service target used during installation:
Targeting the GUI domain:
launchctl bootout gui/$(id -u)/com.circleci.runner
Targeting the user domain:
launchctl bootout user/$(id -u)/com.circleci.runner
-
Uninstall machine runner:
To uninstall without purging logs and configuration files, run the following command.
brew uninstall --cask circleci-public/homebrew-circleci/circleci-runner
CautionThis command will purge all logs and configuration files. To uninstall and purge all logs and configuration files, run the following command.
brew uninstall --cask --zap circleci-public/homebrew-circleci/circleci-runner
On your macOS machine, logs from circleci-runner
are located in the following directory by default.
$HOME/Library/Logs/com.circleci.runner/runner.log