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

# CircleCI

> Connect CircleCI for enhanced failure analysis and automatic fixes

Gitar reads the log of every failing CircleCI job and analyzes it.

CircleCI reports a job to the pull request as a status check. That status links to the job, and Gitar fetches the log from the link.

## Prerequisites

* Confirm CircleCI reports build results to your pull requests as a status check.
* Get access to the CircleCI account you want Gitar to read as. A dedicated account such as `circleci-integration@yourcompany.com` keeps access working when people leave.

## Setup

**1. Create a personal API token**

1. Sign in as the user you want Gitar to read as.
2. Go to [Personal API Tokens](https://app.circleci.com/settings/user/tokens).
3. Click **Create New Token** and name it `Gitar`.
4. Copy the token. CircleCI shows it once.

> [!NOTE]
>
> Gitar needs a Personal API Token, not a Project API Token. The token carries its user's access, so it reads the projects that user can see.

**2. Enter the token in Gitar**

1. Go to your Gitar organization settings.

2. Open **Integrations**.

3. Find **CircleCI** and click **Connect**.

4. Paste the token into **CircleCI Token**.

5. Click **Connect** to save. The card's button changes to **Configure** once the token validates.

CircleCI integration form with the API token field

## What Gitar reads

Gitar reads the log of a failing job and passes it to CI failure analysis. It ignores a passing job. Results appear as a comment on the pull request.

Gitar also reruns a job when analysis classifies its failure as unrelated to your changes, which is the only write it makes to CircleCI.

See [CI failure analysis](https://docs.gitar.ai/features/ci-failure-analysis.md).

## Troubleshooting

> [accordion] Gitar does not comment on a failed job
>
> Check the pull request for a CircleCI status check.
>
> If there is no status, CircleCI is not reporting to your Git provider. Check that the repository is connected to both your Git provider and CircleCI, and that the project is set up in CircleCI.

> [accordion] The token is rejected
>
> Check that you created a Personal API Token, not a Project API Token.
>
> Check that the token has not expired or been revoked. Tokens are listed under [Personal API Tokens](https://app.circleci.com/settings/user/tokens) for the user that made them.

> [accordion] Log fetching fails on a job that exists
>
> The token resolves but its user cannot see the project. Use a token from a user who can already open that job in CircleCI.

## Security notes

* Gitar encrypts credentials and stores them in AWS Secrets Manager.
* Prefer a dedicated user's token over a personal one, so access survives people leaving.
* To revoke access, delete the token from the user's [Personal API Tokens](https://app.circleci.com/settings/user/tokens) page.


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