Guide for GitLab (Self-Managed)

Integrate the AI Code Review Agent into your self-hosted GitLab workflow.

Speed up code reviews by configuring the AI Code Review Agent with your GitLab (Self-Managed) server. In this guide, you'll learn how to set up the Agent to receive automated code reviews that trigger whenever you create a merge request, as well as how to manually initiate reviews using available commands.

The Free Plan offers AI-generated pull request summaries to provide a quick overview of changes. For advanced features like line-level code suggestions, consider upgrading to the 10X Developer Plan. For detailed pricing information, visit our Pricing page.

Get a 14-day FREE trial of Bito's AI Code Review Agent.

Video tutorial

coming soon...

Prerequisites

Before proceeding, ensure you've completed all necessary prerequisites.

1. Create a GitLab Personal Access Token:

For GitLab merge request code reviews, a token with api scope is required. Make sure that the token is created by a GitLab user who has the Maintainer access role.

View Guide

We recommend setting the token expiration to at least one year. This prevents the token from expiring early and avoids disruptions in the AI Code Review Agent's functionality.

Additionally, we highly recommend updating the token before expiry to maintain seamless integration and code review processes.

2. Authorizing a GitLab Personal Access Token for use with SAML single sign-on:

If your GitLab organization enforces SAML Single Sign-On (SSO), you must authorize your Personal Access Token through your Identity Provider (IdP); otherwise, Bito's AI Code Review Agent won't function properly.

For more information, please refer to these GitLab documentation:

Installation and configuration steps

Follow the step-by-step instructions below to install the AI Code Review Agent using Bito Cloud:

Step 1: Log in to Bito

Log in to Bito Cloud and select a workspace to get started.

Step 2: Open the Code Review Agents setup

Navigate to the Code Review Agents setup page via the sidebar.

Step 3: Select your Git provider

Bito supports integration with the following Git providers:

  • GitHub

  • GitHub (Self-Managed)

  • GitLab

  • GitLab (Self-Managed)

  • Bitbucket

Since we are setting up the Agent for GitLab (Self-Managed) server, select GitLab (Self-Managed) to proceed.

Supported versions:

  • GitLab (Self-Managed): 15.5 and above

Step 4: Connect Bito to GitLab

To enable merge request reviews, you’ll need to connect your Bito workspace to your GitLab (Self-Managed) server.

If your network blocks external services from interacting with the GitLab server, whitelist all of Bito's gateway IP addresses in your firewall to ensure Bito can access your self-hosted repositories. The Agent response can come from any of these IPs.

  • List of IP addresses to whitelist:

    • 18.188.201.104

    • 3.23.173.30

    • 18.216.64.170

You need to enter the details for the below mentioned input fields:

  • Hosted GitLab URL: This is the domain portion of the URL where you GitLab Enterprise Server is hosted (e.g., https://yourcompany.gitlab.com). Please check with your GitLab administrator for the correct URL.

  • Personal Access Token: Generate a GitLab Personal Access Token with api scope in your GitLab (Self-Managed) account and enter it into the Personal Access Token input field. For guidance, refer to the instructions in the Prerequisites section.

Click Validate to ensure the token is functioning properly.

If the token is successfully validated, you can select your GitLab Group from the dropdown menu.

Click Connect Bito to GitLab to proceed.

Step 5: Enable AI Code Review Agent on repositories

After connecting Bito to your GitLab self-managed server, you need to enable the AI Code Review Agent for your repositories.

Click the Go to repository list button to view all repositories Bito can access in your GitLab self-managed server.

Use the toggles in the Code Review Status column to enable or disable the Agent for each repository.

To customize the Agent’s behavior, you can edit existing configurations or create new Agents as needed.

Learn more

Step 6: Automated and manual merge request reviews

Once a repository is enabled, you can invoke the AI Code Review Agent in the following ways:

  1. Automated code review: By default, the Agent automatically reviews all new merge requests and provides detailed feedback.

  2. Manually trigger code review: To initiate a manual review, simply type /review in the comment box on the merge request and submit it. This action will start the code review process.

The AI-generated code review feedback will be posted as comments directly within your merge request, making it seamless to view and address suggestions right where they matter most.

Note: To enhance efficiency, the AI Code Review Agent is disabled by default for merge requests involving the "main" or "master" branches. This prevents unnecessary processing and token usage, as changes to these branches are typically already reviewed in release or feature branches. To modify this default behavior and include the "main" or "master" branches, you can use the Source or Target branch filter.

The AI Code Review Agent automatically reviews code changes up to 5000 lines when a merge request is created. For larger changes, you can use the /review command.

It may take a few minutes to get the code review posted as a comment, depending on the size of the merge request.

Step 7: Specialized commands for code reviews

Bito also offers specialized commands that are designed to provide detailed insights into specific areas of your source code, including security, performance, scalability, code structure, and optimization.

  • /review security: Analyzes code to identify security vulnerabilities and ensure secure coding practices.

  • /review performance: Evaluates code for performance issues, identifying slow or resource-heavy areas.

  • /review scalability: Assesses the code's ability to handle increased usage and scale effectively.

  • /review codeorg: Scans for readability and maintainability, promoting clear and efficient code organization.

  • /review codeoptimize: Identifies optimization opportunities to enhance code efficiency and reduce resource usage.

By default, the /review command generates inline comments, meaning that code suggestions are inserted directly beneath the code diffs in each file. This approach provides a clearer view of the exact lines requiring improvement. However, if you prefer a code review in a single post rather than separate inline comments under the diffs, you can include the optional parameter: /review #inline_comment=False

For more details, refer to Available Commands.

Screenshots

Screenshot # 1

AI-generated merge request (MR) summary

Screenshot # 2

Changelist showing key changes and impacted files in a merge request.

Screenshot # 3

AI code review feedback posted as comments on the merge request.

Last updated

Was this helpful?