---
title: Linking code from Gerrit
sidebarTitle: Gerrit
icon: crow
---

import GerritSchema from '/snippets/schemas/v3/gerrit.schema.mdx'

<Note>Authenticating with Gerrit is currently not supported. If you need this capability, please raise a [feature request](https://github.com/sourcebot-dev/sourcebot/issues/new?template=feature_request.md).</Note>

Sourcebot can sync code from self-hosted gerrit instances.

If you're not familiar with Sourcebot [connections](/docs/connections/overview), please read that overview first.

## Connecting to a Gerrit instance

To connect to a gerrit instance, provide the `url` property to your config:

```json
{
    "type": "gerrit",
    "url": "https://gerrit.example.com"
    // .. rest of config ..
}
```

## Examples

<AccordionGroup>
    <Accordion title="Sync projects by glob pattern">
        ```json
        {
            "type": "gerrit",
            "url": "https://gerrit.example.com",
            // Sync all repos under project1 and project2/sub-project
            "projects": [
                "project1/**",
                "project2/sub-project/**"
            ]
        }
        ```
    </Accordion>
    <Accordion title="Exclude repos from syncing">
        ```json
        {
            "type": "gerrit",
            "url": "https://gerrit.example.com",
            // Sync all repos under project1 and project2/sub-project...
            "projects": [
                "project1/**",
                "project2/sub-project/**"
            ],
            // ...except:
            "exclude": {
                // any project that matches these glob patterns
                "projects": [
                    "project1/foo-project",
                    "project2/sub-project/some-sub-folder/**"
                ],

                // projects that have state READ_ONLY
                "readOnly": true,

                // projects that have state HIDDEN
                "hidden": true
            }
        }
        ```
    </Accordion>
</AccordionGroup>

## Schema reference

<Accordion title="Reference">
[schemas/v3/gerrit.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/gerrit.json)

<GerritSchema />

</Accordion>