Sourcebot can sync code from GitLab.com, Self Managed (CE & EE), and Dedicated. If you’re not familiar with Sourcebot connections, please read that overview first.

Examples

Authenticating with GitLab

In order to index private projects, you’ll need to generate a GitLab Personal Access Token (PAT). Create a new PAT here and make sure you select the read_api scope: GitLab PAT Scope Next, provide the PAT via the token property, either as an environment variable or a secret:
Environment variables are only supported in a declarative config and cannot be used in the web UI.
  1. Add the token property to your connection config:
{
    "type": "gitlab",
    "token": {
        // note: this env var can be named anything. It
        // doesn't need to be `GITLAB_TOKEN`.
        "env": "GITLAB_TOKEN"
    }
    // .. rest of config ..
}
  1. Pass this environment variable each time you run Sourcebot:
    docker run \
        -e GITLAB_TOKEN=<PAT> \
        /* additional args */ \
        ghcr.io/sourcebot-dev/sourcebot:latest

Connecting to a custom GitLab host

To connect to a GitLab host other than gitlab.com, provide the url property to your config:
{
    "type": "gitlab",
    "url": "https://gitlab.example.com"
    // .. rest of config ..
}

Troubleshooting

  • If you’re seeing errors like GitbeakerTimeoutError: Query timeout was reached when syncing a large number of projects, you can increase the client’s timeout by setting the GITLAB_CLIENT_QUERY_TIMEOUT_SECONDS environment variable. #162

Schema reference