Integrating CodeRabbit with GitLab.com
This guide will assist you in effectively integrating CodeRabbit with SaaS GitLab.
How it works
For the CodeRabbit app to post reviews on merge requests, it needs to interact with the GitLab API, which requires a Personal Access Token. This token can be generated either by using our default CodeRabbit user or by creating a Personal Access Token from one of your existing users.
The CodeRabbit default user is already set up in GitLab SaaS and will be added to your project when you install the CodeRabbit app. During installation, the necessary webhook for the project will also be created.
If your organization prefers to use an organization user, you can create a new user in GitLab and generate a Personal Access Token for that user, following our recommendations.
Keep in mind that if you want to change the review user, you can either disable the organization user or add a new user via the CodeRabbit UI. However, this will require manually removing the previous user from the projects and associated webhooks. Afterward, you will need to reinstall the CodeRabbit app for each project.
GitLab Access Tokens
To interact with the GitLab API, a Personal Access Token is required. This token can either be generated by using our default CodeRabbit user or by creating a Personal Access Token from one of your existing users.
Upon first login to the application (immediately after the onboarding screen), you will need to choose based on your organization's requirements.
We recommend using the default CodeRabbit user for most organizations, as it is pre-configured. However, we understand that some organizations may prefer more control over the user or have restrictions regarding user inclusion within their organization.
Personal Access Tokens
If your organization opts to use another user within the organization, you can do so by generating a personal access token.
Recommendations
- Create a dedicated user for CodeRabbit - This ensures the user is exclusively for CodeRabbit, allowing better access control.
- Use "CodeRabbit" as the username - This makes the user easily recognizable for future reference.
- Use a dedicated email address - This helps in easy identification and management.
- Use the CodeRabbit logo as the profile picture - This further ensures easy recognition. You can download our logo from here.
Key Points to Remember
- Personal access tokens have expiration dates. Ensure the expiration date covers the duration of your intended use of the CodeRabbit app.
- Code reviews will be attributed to the owner of the personal access token.
- If the personal access token expires, you can add a new one via the CodeRabbit UI:
- Navigate to the "GitLab User" page in the sidebar.
- Click the "Update" button on the displayed card to see the same modal as the initial login.
Generating a Personal Access Token
GitLab provides an option to generate a personal access token for a new user. Follow these steps to generate the token:
- Log in as the user intended for CodeRabbit reviews.
- Select your avatar on the left sidebar.
- Choose "Edit Profile."
- Select "Access Tokens" from the left sidebar.
- Click "Add New Token."
- Enter a name and an expiry date for the token.
- If no expiry date is entered, it defaults to 365 days from the current date.
- Ensure the following scopes are selected:
api
,read_api
,read_user
. - Click "Create Personal Access Token."
- Note down the token as it will only be displayed once.