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

# Run the Orka CLI from parallel CI jobs

> Give each CI job its own Orka CLI configuration, so parallel jobs on one machine don't overwrite each other's settings and fail at random.

When several CI jobs run on one machine under the same user account, they share the Orka CLI's local configuration. Jobs that write it at the same time can break each other, and the failures look random. Giving each job its own configuration directory prevents this.

## What the CLI keeps on disk

The Orka CLI keeps its state in two files under `$HOME`:

* `~/.config/configstore/orka-cli.json` holds the Orka API URL, set by `orka config set --api-url`.
* `~/.kube/config` holds the cluster connection and token, set by `orka login` or `orka user set-token`.

Almost every `orka` command reads `orka-cli.json`, and `orka config set` rewrites it in place. If one job reads the file while another is rewriting it, the reading job gets an empty or partial file and fails with:

```
could not read Orka config: unexpected end of JSON input
```

The failure is intermittent and a retry usually passes, so it's easy to mistake for a network problem. Retrying doesn't fix it, though: nearly any `orka` command in any job can hit it, including the delete at the end of a job.

Jobs that use different clusters or service accounts have a second problem. The CLI stores one Orka connection in `~/.kube/config`, so the last job to run `orka user set-token` decides which token every job on the machine uses.

## Give each job its own HOME for the Orka CLI

Point `HOME` at a directory of the job's own, for `orka` commands only:

```bash theme={null}
export ORKA_HOME="$(mktemp -d)"
orka() { HOME="$ORKA_HOME" command orka "$@"; }
trap 'rm -rf "${ORKA_HOME:?}"' EXIT

orka config set --api-url <ORKA_API_URL>
orka user set-token "$ORKA_TOKEN"
orka vm deploy <VM_NAME> --config <VM_CONFIGURATION_NAME>
```

Each job now has its own `orka-cli.json` and `~/.kube/config`, and the directory is removed when the job exits.

Change `HOME` for `orka` only, not for the whole job. SSH agents, Git, cloud CLIs, and CI hooks keep their own files under `HOME` and expect the real one.

If your CI runs later steps or hooks in child shells, export the function so they inherit it:

```bash theme={null}
export ORKA_HOME
export -f orka
```

`export -f` works in bash only. In other shells, put the same one-line wrapper in a script on the job's `PATH` ahead of the real `orka` binary.

## When you need this

* Several CI agents or executors on one machine under one user account, such as multiple Buildkite agents, a GitLab Runner with the shell executor and `concurrent` above 1, or a Jenkins agent with more than one executor.
* Jobs on one machine that talk to different Orka clusters or use different service accounts.

Jobs that already run in their own container or VM each have their own `HOME` and aren't affected.

## Related pages

* [Orka CLI Overview & Configuration](https://docs.macstadium.com/orka/orka-cli-reference/orka-cli-overview-configuration.md)
* [Understanding Orka credentials](https://docs.macstadium.com/orka/orka-cluster-access/understanding-orka-credentials.md)
* [Buildkite agents on Orka macOS VMs](https://docs.macstadium.com/orka/orka-devops-integrations/buildkite.md)


## Related topics

- [Orka tools, CLI downloads, and CI/CD plugins](https://docs.macstadium.com/orka/orka-overview/tools-integrations.md)
- [Use a fresh VM for each CI job](https://docs.macstadium.com/orka/orka-best-practices/one-vm-per-job.md)
- [Azure DevOps agents on Orka](https://docs.macstadium.com/orka/orka-devops-integrations/azure-devops.md)
- [GitHub Actions integration for Orka](https://docs.macstadium.com/orka/orka-devops-integrations/github-actions.md)
- [Orka CI/CD integrations quick start guide](https://docs.macstadium.com/orka/quick-start-guides/cicd-integrations-quick-start.md)


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