Machine runner 3.0 manual installation

3 weeks ago3 min read
Last updated • Read time
Cloud
This document is applicable to CircleCI Cloud
Server v4.4+
This document is applicable to CircleCI Server v4.4+

This page describes how to manually start CircleCI’s machine runner 3.0 on macOS and Linux.

Prerequisites

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:

  • Coreutils - Linux only

  • Homebrew - macOS only

  • curl (installed by default on macOS)

  • sha256sum (if not pre-installed):

    • brew install coreutils

    • sudo apt install coreutils for Ubuntu/Debain

    • sudo yum install coreutils for Red Hat

  • tar

  • Gzip - Linux only

  • sepolicy ( RHEL 8 only) - Linux only

  • rpmbuild ( RHEL 8 only) - Linux only

  • The CircleCI CLI if you wish to install runners from the command line

Self-hosted runner terms agreement

Before you can install self-hosted runners through the web app, you will need to agree to the CircleCI Runner Terms. To be able to gain access to the Self-Hosted Runners section of the CircleCI web app or your CircleCI server app, an admin in your organization needs to navigate to Organization Settings  Self-Hosted Runners, and agree to the terms.

Runner terms and conditions

Once the terms have been accepted, Self-Hosted Runners will appear permanently in the side navigation.

Your role within your org is determined differently depending on how you integrate with your code, as follows:

  • If your code is integrated with CircleCI via the GitHub OAuth App or Bitbucket Cloud, CircleCI mirrors VCS permissions for organizations. If you are an admin on your organization’s VCS, you are an admin on CircleCI. If you are unsure, check the admin permissions on your VCS.

  • If your code is integrated with CircleCI via the GitHub App, GitLab, or Bitbucket Data Center, you can check roles by navigating to Organization Settings  People. Full details on roles and permissions are available in the Roles and permissions overview.

1. Create namespace and resource class

In order to install self-hosted runners, you will need to create a namespace and authentication token by performing the steps listed below.

You can view your installed runners on the inventory page in the web app or your CircleCI server app, by clicking Self-Hosted Runners on the left navigation.

  1. Create a namespace for your organization’s self-hosted runners. Each organization can only create a single namespace. We suggest using a lowercase representation of your CircleCI organization’s account name. If you already use orbs, this namespace should be the same namespace orbs use.

    Use the following command to create a namespace:

    circleci namespace create <name> --org-id <your-organization-id>
  2. Create a resource class for your self-hosted runner’s namespace using the following command:

    circleci runner resource-class create <namespace>/<resource-class> <description> --generate-token

    Make sure to replace <namespace> and <resource-class> with your org namespace and desired resource class name, respectively. You may optionally add a description.

    Example: circleci runner resource-class create my-namespace/my-resource-class my-description --generate-token.

    The resource class token is returned after the runner resource class is successfully created.

2. Download the CircleCI machine runner

export RUNNERVERSION='current'
export CPUARCH=$(/usr/bin/arch | grep 'x86_64' >/dev/null 2>/dev/null && echo 'amd64' || echo 'arm64')
export OSTARGET=$(uname -s | tr '[:upper:]' '[:lower:]')
curl -s -L "https://circleci-binary-releases.s3.amazonaws.com/circleci-runner/${RUNNERVERSION}/circleci-runner_${OSTARGET}_${CPUARCH}.tar.gz" -o $HOME/circleci-runner.tar.gz && tar -zxvf $HOME/circleci-runner.tar.gz

3. Mark the CircleCI machine runner as executable

Update permissions for your CircleCI machine runner to enable running its binary:

chmod +x $HOME/circleci-runner

4. Create the CircleCI machine runner configuration and working directory

  1. Create the directory in which CircleCI machine runner jobs will start:

    mkdir $HOME/circleci
  2. Create a CircleCI runner configuration file:

    touch $HOME/circleci-runner-config.yaml
  3. Populate the newly created file with the configuration for your runner. An example can be seen below.

    nano $HOME/circleci-runner-config.yaml
    runner:
      name: "my-macos-runner"
      working_directory: "$HOME/circleci"
      cleanup_working_directory: true
    api:
      auth_token: "your-auth-token"
  4. If you are using CircleCI server you will need to provide the URL for your install. You can do this by adding the URL to $HOME/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://runner.circleci.com

5. Start the CircleCI machine runner

$HOME/circleci-runner machine --config $HOME/circleci-runner-config.yaml