> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Run CircleCI jobs on StackShift

> Connect a CircleCI self-hosted runner resource class and each job runs on a fresh computer of the size you pick, deleted when the job ends.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Send CircleCI jobs to StackShift computers with a self-hosted runner resource class.

## Prerequisites

* A StackShift project.
* A CircleCI organization where you can create runner resource classes.

## Workflow

**Step 1**

In CircleCI, open Runners and click Create Resource Class, for example acme/stackshift-medium. You don’t need the token it shows.

**Step 2**

In CircleCI, open User Settings, then Personal API Tokens, and create a token.

**Step 3**

On StackShift, open Computers, then CI. Under CircleCI resource classes, enter the resource class, pick its size, paste your API token and click Connect resource class.

**Step 4**

Set resource\_class in your CircleCI config to the resource class and push.

**Step 5**

Watch the job on the CI page. CircleCI shows its logs as usual.

## What happens

* StackShift watches how many jobs wait on the resource class and starts one computer for each, up to the number you allow at once.
* Each computer runs the CircleCI runner, takes one job and stops. The computer is then deleted, so nothing carries over between jobs.
* Each job gets a runner token made for it alone, and StackShift revokes it when the job ends. Disconnecting the resource class revokes them all.
* Jobs run as the sandbox user, with Docker and sudo.
* A job may run up to 5 hours, CircleCI’s default limit for runners.
* Computers are billed per second like any computer, and the free plan limits for computers apply.

## One resource class per size

A resource class always runs on one size. To offer more sizes, create a resource class for each, such as acme/stackshift-medium and acme/stackshift-large, and connect each with its size: small (2 vCPU, 4 GB), small-mem (2 vCPU, 8 GB), medium (4 vCPU, 8 GB), medium-mem (4 vCPU, 16 GB), large (8 vCPU, 16 GB) or xlarge (16 vCPU, 32 GB).

## Create the resource class from the terminal

You can also create it with the CircleCI CLI.

```bash theme={null}
circleci runner resource-class create acme/stackshift-medium "StackShift medium"
```

## Your CircleCI config

```yaml .circleci/config.yml theme={null}
version: 2.1
jobs:
  build:
    machine: true
    resource_class: acme/stackshift-medium
    steps:
      - checkout
      - run: make test
workflows:
  build:
    jobs:
      - build
```

## Connect with the CLI

The CLI reads your API token from CIRCLECI\_TOKEN, or asks for it when it isn’t set.

```bash theme={null}
export CIRCLECI_TOKEN=...
stackshift computers ci circleci connect acme/stackshift-medium --size medium --max-jobs 5
stackshift computers ci circleci connect acme/stackshift-large --size large --snapshot acme-ci
stackshift computers ci circleci list
stackshift computers ci circleci disconnect <connection-id>
stackshift computers ci jobs
```

## Good to know

* Your API token is stored encrypted and never shown again. To change it, disconnect the resource class and connect it again.
* To start jobs from your own setup, save a snapshot of a ci-runner computer and connect the resource class with that snapshot.
* Use the resource class only for StackShift. Another runner on it could take a job a StackShift computer was started for.
* CircleCI doesn’t run forked pull requests from public projects on self-hosted runners.

## Expected result

> [!TIP]
>
> Each job runs on a fresh ci-runner computer of the connected size, and the computer is deleted when the job ends.

## Common failures

> [!WARNING]
>
> * Jobs stay queued in CircleCI: the note under the resource class on the CI page says why, such as a rejected API token or the jobs-at-once limit.
> * A job shows Taken by another runner: another runner on the same resource class picked it up first. Its computer is deleted without running anything.
> * Waiting for a computer: the reason under the job says what it waits for, such as capacity or funds. It starts as soon as that clears.

## Related guides

> [card] [Run GitHub Actions jobs on computers](https://docs.stackshift.cloud/computers-ci/github-actions.md)
>
> Change runs-on to stackshift-medium and each job runs on a fresh computer of its own, deleted when the job ends.

> [card] [Start jobs from a snapshot](https://docs.stackshift.cloud/computers-ci/snapshots.md)
>
> Save a ci-runner computer with your repository, toolchain and caches, and start jobs from it with stackshift-medium-snapshot-\<name>.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.