# Configure with GitLab

Integrate Baz with GitLab repositories to mirror your codebase and enable Baz’s review capabilities. After signing in to Baz (via GitHub or GitLab), navigate to your workspace and select **Connect to GitLab**. This will prompt you to provide GitLab access credentials and choose which projects to integrate with Baz.

{% hint style="info" %}
**Note:** If an administrator has already configured a GitLab integration for your organization, simply login to Baz using GitLab to configure relevant projects.
{% endhint %}

## Configure GitLab.com

### Provide a GitLab Personal Access Token

When connecting Baz to GitLab, you’ll be asked to enter a GitLab **Personal Access Token (PAT)**. This token allows Baz to call the GitLab API on behalf of the PAT owner.

To generate a PAT, go to your GitLab account’s **Settings > Access Tokens**. We recommend creating a new user as a service account, associating this user to the group you’d like to install Baz on, and providing it with the personal access token to allow access. The PAT needs to have the following scopes:&#x20;

* `api`  - to allow us to read and update PRs
* `read_user` - to allow onboarding of the rest of the organization's users and their permissions.

{% hint style="success" %}
Before proceeding, ensure the service account created has the `developer` permissions.
{% endhint %}

Once you have the PAT, enter it in Baz’s **Connect to GitLab**. Baz will securely store the token and verify it. By default Baz connects to **gitlab.com,** if you self-host GitLab change it to your custom domain.&#x20;

Also, if you are self hosting, please allow our three public IP addresses: `18.190.165.140`, `3.20.124.148`, `3.12.220.91` .

After submitting the token, you’ll see a confirmation message indicating that Baz is connected.

### Select GitLab Projects to Integrate

After connecting with your PAT, Baz will retrieve the list of GitLab projects that it has access to. You’ll see this list in Baz’s interface, where you can choose which repositories to integrate.

<figure><img src="https://3328658395-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVjqbueGEV6lEh1M5NENO%2Fuploads%2F5KSK9QYAx4TSNWwH90Zv%2Fimage.png?alt=media&#x26;token=aa0c86e4-5a86-4bdb-9d70-bbd94addf52f" alt="Select projects" width="563"><figcaption></figcaption></figure>

Select the ones you want Baz to review. Once confirmed, Baz will sync the chosen repositories into your Baz workspace. This includes cloning the repositories, indexing their code, and synchronizing GitLab groups and members associated with those projects.

From here, your Baz workspace mirrors your GitLab projects. In the **Agents** section, you’ll see which Reviewers are active in your projects. In the **Changes** section, you can access merge requests from projects, ready for review.

### Performing Reviews (Comments & Merges)

Once integrated, Baz can help review code changes from your GitLab projects. Comments or merge actions performed in Baz will appear directly on GitLab merge requests, authored by the account tied to the PAT.

### Update the GitLab Integration

You can reconfigure the GitLab integration at any time from **Settings > Integrations**.

* **Add/Remove Projects:** Open the project list again and adjust which repositories are synced. Baz will add any newly selected repositories or stop syncing deselected ones.
* **Update Credentials:** To update credentials, create a new integration.

## Configure GitLab On-prem

For self-managed GitLab instances, **the initial setup follows the same steps as GitLab SaaS** above:

1. Generate a Personal Access Token
2. Integrate your GitLab instance
3. Select your repositories

However, webhook registration must be done manually as detailed below.

### Setting up webhooks

After completing the integration setup as defined above for GitLab.com and selecting your repositories:

1. Contact Baz support (<support@baz.co>) to obtain your Integration ID and Secret token.
2. In your GitLab instance, navigate to the group you want to connect:

* Go to Settings > Webhooks
* Select Add new webhook

3. Configure the webhook with the following settings:

* URL: [https://baz.co/api/v2/webhooks/gitlab/{integrationId}](https://baz.co/api/v2/webhooks/gitlab/%7BintegrationId%7D) (replace {integrationId} with the ID provided by Baz)
* Secret token: paste the secret provided by Baz

4. In the Trigger section, enable the following `Push events`, `Merge request events`, `Issue events` `Job events`, `Pipeline events`, `Note events`, `Member events`
5. Select `Add webhook` to save.
6. Repeat steps 2–5 for each group whose repositories you selected during setup. No need to do this for subgroups of a group that has a webhook.

## FAQ

<details>

<summary><strong>Does Baz support GitLab out of the box?</strong></summary>

Yes. Baz provides instructions on integrating with GitLab so that merge requests are automatically reviewed by Baz.

</details>

<details>

<summary>What permissions are necessary for GitLab integration?</summary>

Baz needs read access to code and merge request metadata, and permission to post comments in the MR discussion. The permissions

</details>

<details>

<summary>Are there limitations or feature parity differences between GitHub vs GitLab integration?</summary>

There may be slight differences (e.g. event triggers, comment threading) that impact agent responsiveness but overall both integrations are identical.

</details>
