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

# Self-Hosted GitLab Setup

> Set up GitLab sign-in, connect your projects, and receive your first merge request review.

For self-hosted GitLab, first create an OAuth application for CodeAnt sign-in. Then save an access token and install project webhooks to enable reviews.

## Before you begin

* Permission to create an OAuth application in your GitLab instance.
* **Maintainer** access to the projects you want reviewed, for the account whose access token CodeAnt will use.
* Your GitLab base URL, such as `https://gitlab.example.com`.
* A project where you can open a merge request.

Confirm your GitLab version is supported with [CodeAnt support](mailto:support@codeant.ai) before a production rollout. If your instance is private, check the network requirements below before creating credentials.

## Network requirements

Your GitLab instance and CodeAnt need access in both directions:

| Connection | Needed for |
| - | - |
| CodeAnt to your GitLab instance | OAuth sign-in, GitLab API calls, HTTPS repository access, and webhook installation |
| GitLab to `https://vcs.codeant.ai` over HTTPS on port 443 | Merge request and comment webhook delivery |

Use a valid TLS certificate and keep SSL verification enabled on webhooks. Contact [CodeAnt support](mailto:support@codeant.ai) for the egress IPs to allow through your firewall. If your instance only allows SSH cloning, confirm transport support and key configuration with support before continuing.

## Create the OAuth application

**1. Open GitLab application settings**

Sign in to your GitLab instance with an account that can create the application. Open your profile menu, select **Edit profile**, and find **Applications**. Select **Add new application**.

GitLab supports user-owned and instance-wide OAuth applications. See [GitLab's OAuth application guide](https://docs.gitlab.com/integration/oauth_provider/) if your version uses different navigation.

**2. Configure CodeAnt sign-in**

Enter these values:

| Field | Value |
| - | - |
| Application name | `CodeAnt AI Integration` |
| Redirect URI | `https://app.codeant.ai` |
| Confidential | Enabled |
| Scopes | `api`, `read_api`, `read_user`, `write_repository`, `profile` |

Use the redirect URI exactly as shown. Select **Save application**.

**3. Copy the application credentials**

Copy the **Application ID** and **Secret** from the saved application. Keep them secure; you will enter them in CodeAnt next.

## Connect CodeAnt to your instance

**1. Open self-hosted GitLab sign-in**

Open the [CodeAnt AI dashboard](https://app.codeant.ai), select **Self-Hosted**, and choose **GitLab Self-Managed**. Enter your GitLab base URL.

**2. Register the OAuth credentials**

If CodeAnt does not yet have an OAuth client for that URL, it opens **Self-Hosted GitLab Details**. Enter the **Application ID** and **Secret** you copied above.

![CodeAnt self-hosted GitLab form for the OAuth Application ID and Secret](https://mintcdn.com/codeantai/sZZf2QxHoZY37Zrw/images/setup/gitlab/self-hosted/oauth_conf.png?fit=max\&auto=format\&n=sZZf2QxHoZY37Zrw\&q=85\&s=4fecd817620282f5a86819c1e4c0977b)

**3. Authorize sign-in**

CodeAnt redirects you to your GitLab instance. Authorize the application to return to CodeAnt signed in.

For subsequent sign-ins, choose **GitLab Self-Managed** and enter the same base URL. CodeAnt uses the saved OAuth client.

## Connect projects and get your first review

Sign-in completes the OAuth setup. To let CodeAnt fetch changes and post review comments, you also need an access token and webhooks.

1. Follow the [GitLab access token guide](https://docs.codeant.ai/setup/gitlab/access-token.md) to create a token with `api` and `write_repository` scopes.
2. Save it in CodeAnt under **Settings** → **Configure Token** → **Save & Configure Webhooks**.
3. Select a project on **Configure Repository Webhooks** and select **Create Webhooks (N)**. Confirm that installation succeeds.
4. Open a new merge request in that project and check for CodeAnt's review feedback on the MR.

To request a review on an existing MR, post:

```text theme={"theme":"css-variables"}
@codeant-ai: review
```

If you need to create project or group webhooks yourself, use the [manual webhook guide](https://docs.codeant.ai/setup/gitlab/manual-webhooks.md).

## Troubleshooting

> [accordion] GitLab reports a redirect URI mismatch
>
> Edit the GitLab OAuth application and set **Redirect URI** to exactly `https://app.codeant.ai`, matching the setup above. Save the application and retry sign-in.

> [accordion] Sign-in works, but projects are missing
>
> Confirm that an access token is saved in **Settings** → **Configure Token**. The OAuth application handles sign-in; the token's identity must have Maintainer access to the projects you want reviewed.

> [accordion] Webhook installation fails
>
> Check the token's scopes and Maintainer access for the affected project. Confirm that CodeAnt can reach the GitLab API through your firewall. Fix the permission or connectivity issue, then reconfigure the token and retry installation.

> [accordion] GitLab cannot deliver webhook events
>
> In the project, open **Settings** → **Webhooks** and test the merge request webhook. Check that GitLab can reach `vcs.codeant.ai` over HTTPS and that SSL verification is enabled. A 2xx response confirms delivery, not a completed review.

> [accordion] My merge request has not received a review
>
> Confirm that webhook installation succeeded and that the saved access token is valid. Post `@codeant-ai: review` on the MR. If feedback still does not appear, [contact CodeAnt support](mailto:support@codeant.ai) with your GitLab version, instance URL, project, MR URL, and webhook response. Do not include the token or OAuth Secret.

## Next steps

> [card] [Customize your reviews](https://docs.codeant.ai/pull_request/customize/rules.md)
>
> Add review rules for your team's coding standards.

> [card] [Configure repository scans](https://docs.codeant.ai/repositories/analysis_configuration.md)
>
> Choose which analyses run and which files they include.


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