> ## Documentation Index
> Fetch the complete documentation index at: https://sourcebot-brendan-scim-user-provisioning.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Linking code from Gerrit

<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/indexing-your-code), please read that overview first.

## Connecting to a Gerrit instance

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

```json theme={null}
{
    "type": "gerrit",
    "url": "https://gerrit.example.com",
    // Specify which projects to sync using glob patterns:
    "projects": ["project1/**"]
}
```

## Examples

<AccordionGroup>
  <Accordion title="Sync projects by glob pattern">
    ```json theme={null}
    {
        "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 theme={null}
    {
        "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)

  ```json theme={null}
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "GerritConnectionConfig",
    "properties": {
      "type": {
        "const": "gerrit",
        "description": "Gerrit Configuration"
      },
      "url": {
        "type": "string",
        "format": "url",
        "description": "The URL of the Gerrit host.",
        "examples": [
          "https://gerrit.example.com"
        ],
        "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
      },
      "projects": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "List of specific projects to sync. If not specified, all projects will be synced. Glob patterns are supported",
        "examples": [
          [
            "project1/repo1",
            "project2/**"
          ]
        ]
      },
      "exclude": {
        "type": "object",
        "properties": {
          "projects": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "project1/repo1",
                "project2/**"
              ]
            ],
            "description": "List of specific projects to exclude from syncing."
          },
          "readOnly": {
            "type": "boolean",
            "default": false,
            "description": "Exclude read-only projects from syncing."
          },
          "hidden": {
            "type": "boolean",
            "default": false,
            "description": "Exclude hidden projects from syncing."
          }
        },
        "additionalProperties": false
      },
      "revisions": {
        "type": "object",
        "description": "The revisions (branches, tags) that should be included when indexing. The default branch (HEAD) is always indexed. A maximum of 64 revisions can be indexed, with any additional revisions being ignored.",
        "properties": {
          "branches": {
            "type": "array",
            "description": "List of branches to include when indexing. For a given repo, only the branches that exist on the repo's remote *and* match at least one of the provided `branches` will be indexed. The default branch (HEAD) is always indexed. Glob patterns are supported. A maximum of 64 branches can be indexed, with any additional branches being ignored.",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "main",
                "release/*"
              ],
              [
                "**"
              ]
            ],
            "default": []
          },
          "tags": {
            "type": "array",
            "description": "List of tags to include when indexing. For a given repo, only the tags that exist on the repo's remote *and* match at least one of the provided `tags` will be indexed. Glob patterns are supported. A maximum of 64 tags can be indexed, with any additional tags being ignored.",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "latest",
                "v2.*.*"
              ],
              [
                "**"
              ]
            ],
            "default": []
          }
        },
        "additionalProperties": false
      },
      "enforcePermissions": {
        "type": "boolean",
        "description": "Controls whether repository permissions are enforced for this connection. When `PERMISSION_SYNC_ENABLED` is false, this setting has no effect. Defaults to the value of `PERMISSION_SYNC_ENABLED`. See https://docs.sourcebot.dev/docs/features/permission-syncing"
      },
      "enforcePermissionsForPublicRepos": {
        "type": "boolean",
        "default": false,
        "description": "Controls whether repository permissions are enforced for public repositories in this connection. When true, public repositories are only visible to users with a linked account for this connection's code host. When false, public repositories are visible to all users. Has no effect when enforcePermissions is false. Defaults to false. See https://docs.sourcebot.dev/docs/features/permission-syncing"
      }
    },
    "required": [
      "type",
      "url"
    ],
    "additionalProperties": false
  }
  ```
</Accordion>
