The self-hosted option is only available for CodeRabbit Enterprise customers
with 500 user seats or more. Please contact CodeRabbit
Sales to learn more about the CodeRabbit
Enterprise plan.
Create a GitLab User
- Username: Set the username to “CodeRabbit” for easier identification (optional).
- Profile Image: Use the CodeRabbitAI logo for the user image (optional).
Add User to Projects
Add the CodeRabbit user to each project where you want CodeRabbit to post reviews, with at leastDeveloper
access.
Create a Personal Access Token for CodeRabbit user
Generate a personal access token for the CodeRabbit user to be added in the.env
file as GITLAB_BOT_TOKEN
.
Necessary Scopes:
api
Add a webhook to each project
1
Navigate to Add Webhook Page
Go to the webhook configuration page in the desired GitLab project.
2
Add Webhook URL
Enter the URL pointing to the CodeRabbit service, followed by
/gitlab_webhooks
(e.g., http://127.0.0.1:8080/gitlab_webhooks
).3
Generate and Save Secret Token
Generate a secret token, add it to the webhook, and store it securely. This
will be needed for the
.env
file as GITLAB_WEBHOOK_SECRET
(you can use a
single secret token for all projects).4
Select triggers
Enable the following webhook triggers: - Push events - Comments - Issues
events - Merge request events
Add Webhook Using a Script
We have a convenient script to help you add webhooks to a project or all projects under a group in a GitLab instance.Prepare a .env
file
Create a .env
file with the following content:
.env
- If you are using Azure OpenAI, verify that the model deployment names are in the .env file.
- Values marked with [] are not optional to provide.
- You can generate
CODERABBIT_API_KEY
from CodeRabbit UI -> Organizations Settings -> API Keys. YAML_CONFIG
is an optional configuration file that can be used to customize CodeRabbit’s behavior at the deployment level. It takes the same format as the CodeRabbit YAML configuration file. It requires the entire YAML file to be in an escaped string format, for example,YAML_CONFIG="key1: value1\nkey2: value2"
. You can use Escape YAML to generate the escaped string.
Pull the CodeRabbit Docker image
Authenticate and pull the Docker image using the provided credentials file:Host the image
You can host the image on a server, serverless function, or container environment and expose port8080
. Run the Docker image with the equivalent command on your chosen platform, ensuring you replace the .env
file path with the path to your actual .env
file:
Verify the image is up
You can query/health
endpoint to verify that the coderabbit-agent service is up and running.