Guide for GitHub Enterprise (self-hosted)

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

Boost your development workflow by configuring the AI Code Review Agent with your GitHub Enterprise (self-hosted) repositories. In this guide, you'll learn how to set up the Agent to receive automated code reviews that trigger whenever you create a pull request, as well as how to manually initiate reviews using available commands.

You need a Bito 10X Developer paid plan to get started. For more information about costs, please 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 GitHub Personal Access Token (classic): For GitHub pull request code reviews, ensure you have a CLASSIC personal access token with "repo" access. We do not support fine-grained tokens currently. View Guide

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

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

    For detailed instructions, please refer to the GitHub documentation.

Installation and configuration steps

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

  1. Log in to Bito Cloud with a workspace subscribed to the Bito 10X Developer plan.

  2. From the left sidebar, click on the Explore Agents menu to view all available Agents for installation.

Currently, we only offer the AI Code Review Agent. More dev agents are coming soon.

  1. Find the Code Review Agent in the list and click the Create New Instance button.

  2. Configure Agent:

    • From the Git provider dropdown menu, select GitHub Enterprise (self-hosted).

    • Whitelist all of Bito's gateway IP addresses in your firewall to ensure Bito has access to your self-hosted repository. 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

    • Enter your GitHub Enterprise (self-hosted) URL.

Supported versions:

  • GitHub Enterprise (self-hosted): 3.0 and above

  • Generate a Personal Access Token (classic) in your GitHub account and enter it into the GitHub Access Token input field. For guidance, refer to the instructions in the Prerequisites section.

  • Agent actions: This section contains all the actions that the AI Code Review Agent can perform. The Agent can execute these actions as part of a workflow or manually.

    • /review command: Initiate a manual code review by commenting /review on a pull request. It provides separate code suggestions for each detected issue below the code diffs.

    • Additionally, you can pass an optional parameter like /review #inline_comment=False to get code review in a single post.

  • Agent instance details: In this section, you can set the name and description of your Agent instance.

    • Instance name: Assign a unique alphanumeric identifier for your instance. You can invoke the Agent in supported clients using @<instance_name> command.

    • Instance description: Provide a brief description of the specific use case or project where this AI Code Review Agent instance will be deployed. This description will help you easily identify and manage it among multiple instances.

  • Filters: Exclude specific files and folders from code reviews or skip automated reviews for selected Git branches. For more information and examples, see Excluding Files, Folders, or Branches with Filters.

    • Files and folders: A list of files/folders that the AI Code Review Agent will not review if they are present in the diff. You can specify the files/folders to exclude from the review by name or glob/regex pattern. The Agent will automatically skip any files or folders that match the exclusion list. This filter applies to both manual reviews initiated through the /review command and automated reviews triggered via webhook.

    • Source or Target branch: This filter allows users to skip automated reviews for pull requests based on the source or target branch. It is useful in scenarios where automated reviews are unnecessary or could potentially disrupt the workflow. This filter applies only to automatically triggered reviews. Users should still be able to trigger reviews manually via the /review command.

    • Draft pull requests: A toggle switch that controls the automated review of pull requests (PR) based on their draft status. The default setting is enabled (turned on), which means automated review is skipped for draft pull requests.

  • Save configuration: Click Save & view setup instructions to complete the installation and access detailed instructions on configuring the new Agent instance with your repository using webhook.

  1. Add Webhook:

    • You will be redirected to a page that provides the webhook payload URL and secret key needed to set up a webhook in GitHub, along with a detailed step-by-step guide. Follow the guide to successfully integrate the AI Code Review Agent with your repository.

      We have also provided a step-by-step guide below to assist you in adding a webhook in GitHub.

Webhook setup guide

You can also consult the official GitHub documentation to learn how to create a webhook.

  1. Login to your GitHub account.

  2. Navigate to the main page of the repository. Under your repository name, click Settings.

  3. In the left sidebar, click Webhooks.

  4. Click Add webhook.

  5. Copy the Payload URL from the Setup Instructions screen on Bito Cloud. Then, navigate to the webhook creation form in GitHub, and in Payload URL input field, paste the URL of the webhook endpoint you've just copied. This unique Webhook URL, provided by Bito Cloud, is designed to receive webhook payloads.

  6. Select the Content type “application/json” for JSON payloads.

  7. Copy the Secret token from the Setup Instructions screen on Bito Cloud. Then, navigate to the webhook creation form in GitHub, and in Secret token input field, paste the webhook secret token you've just copied. The Secret token is used to validate payloads.

  8. Click on Let me select individual events to select the events that you want to trigger the webhook. For code review select these:

    • Issue comments - To enable Code Review on-demand by issuing a command in the PR comment.

    • Pull requests - To auto-trigger Code Review when a pull request is created.

    • Pull request review comments - So, you can share feedback on the review quality by answering the feedback question in the code review comment.

  9. To make the webhook active immediately after adding the configuration, select Active.

  10. Click Add webhook.

Using the AI Code Review Agent

After configuring the webhook, you can invoke the AI Code Review Agent in the following ways:

Note: To enhance efficiency, the AI Code Review Agent is disabled by default for pull 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 pull request is created. For larger changes, you can use the /review command.

  1. Automated code review: If the webhook is configured to trigger on the Pull requests event, the Agent will automatically review new pull requests as soon as they are created and post the review feedback as a comment within your PR.

  2. Manually trigger code review: To initiate a manual review, simply type /review in the comment box on the pull request and submit it. If the webhook is configured to trigger on the Issue comments event, this action will start the code review process. The /review command prompts the Agent to review the pull request and post its feedback directly in the PR as a comment.

    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.

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

Screenshots

Screenshot # 1

AI-generated pull request (PR) summary

Screenshot # 2

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

Screenshot # 3

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

Last updated

Logo

Bito Inc. (c) 2024