Skip to main content

GitLab Cloud indexing setup

Make GitLab Cloud content searchable and map users' GitLab identities to their Glean accounts. Use this guide when your connector collects the access token and OAuth settings in one form. You can add GitLab tools through a separate MCP connection.

Setup includes these tasks:

Both OAuth choices map each teammate's GitLab identity to their Glean account. Neither replaces the access token or expands the content the connector can crawl.

Requirements​

Technical requirements​

  • Glean connects to the GitLab REST API at https://gitlab.com/api/v4/ over HTTPS.
  • Glean throttles its crawl to stay within GitLab's API rate limits, backing off in response to GitLab's rate-limit responses.
  • The connector can index projects across multiple top-level groups when the access token can reach them.

Credential requirements​

Gather these values before you start:

  • Access token: a group access token or a personal access token for a service account that can access every group and project Glean should crawl (see Create an access token).
  • Webhook secret token: a value you choose, entered in both GitLab and Glean so Glean can verify incoming webhook events.
  • OAuth application credentials: a client ID and client secret if you use your own GitLab OAuth app. You don't need to supply these credentials when you use Glean's managed app.
  • User-mapping CSV: an optional fallback for teammates who haven't authorized GitLab. See Build the user-mapping file.

Permission requirements​

  • The token must reach every group and project you want Glean to crawl.
  • For automatic webhook creation, the token needs the api scope or both Webhook: Read and Webhook: Create. The token's account must also have permission to create webhooks for the target projects.
  • To create webhooks manually, you need the Maintainer role for a project or the Owner role for a group.

1. Create an access token​

Use a token whose identity can access every group and project you want to index. A group access token belongs to one top-level group. For unrelated top-level groups on GitLab.com, use a personal access token for a service account that can be granted membership in every target group and project.

Invited-group membership crawling

Namespace filters restrict content crawling. Glean can crawl membership data for an invited group outside the allowed content namespaces if the connector token can list the invited group and its members. Content from the invited group remains excluded.

Option A: Group access token (preferred)​

  1. In GitLab, go to a group you want Glean to crawl → Settings → Access tokens → Add new token.
  2. Give it a name, for example Glean GitLab Connector.
  3. Set Role to Owner. This is required for Glean to create webhooks automatically.
  4. Choose the scopes:
    • To let Glean create webhooks automatically, grant the api scope.
    • To keep the token read-only, grant read_api and read_repository. You must then create webhooks manually.
  5. Set an Expiration date per your policy. GitLab requires an expiry.
  6. Select Create and copy the token value. GitLab shows it only once.

See Group access tokens in the GitLab docs.

Group access-token limitation

A group access token can list members only from its associated top-level group. If another group shares content with an invited group outside that top-level group, Glean cannot list the invited group's members with the group access token. Users who access the shared content through that invited group will not see those documents in Glean. Use a token whose identity can access both groups for this scenario.

Option B: Personal access token for a service account​

Create or select a GitLab service account that can access every group and project you intend to index. For multiple unrelated top-level groups, add the account to each target group before creating the token. Use the Owner role on the groups where Glean should create webhooks automatically.

Choose either a classic personal access token with scopes or a fine-grained personal access token with resource-specific permissions.

Create a classic personal access token​

  1. Next to the service account, open the three-dot menu and select Manage access tokens → Add new token.
  2. Give it a name, for example Glean GitLab Connector.
  3. Choose the scopes:
    • To let Glean create webhooks automatically, grant the api scope.
    • To keep the token read-only, grant read_api, read_user, and read_repository. You must then create webhooks manually. See Create webhooks manually.
  4. Set an Expiration date per your policy. GitLab requires an expiry.
  5. Click Create and copy the token value. GitLab shows it only once.

Configure a fine-grained personal access token​

Create a fine-grained personal access token for the service account. Include every group and project Glean should crawl in the token's resource scope, and grant these permissions:

  • Project: Read
  • Group: Read
  • Member: Read
  • User: Read
  • Code: Download
  • Merge Request: Read
  • Work Item: Read
  • Wiki: Read
  • Personal Access Token: Read
  • Webhook: Read

For automatic webhook creation, also grant Webhook: Create. Glean needs both Webhook: Read and Webhook: Create to list existing hooks and create missing hooks.

Copy the token value for the Glean setup form. For GitLab's permission reference, see Fine-grained permissions for REST API.

note

For manual webhook setup, clear API token has write privileges in the Glean Admin console. This applies to classic tokens with read-only scopes and fine-grained tokens without webhook creation permission. See Configure in Glean.

2. Create webhooks manually​

Skip this step if you use automatic webhook creation. The token must have the api scope or both Webhook: Read and Webhook: Create, and its account must have permission to create webhooks for the target projects. Select API token has write privileges when you configure the connector in Glean.

Otherwise, create a webhook for each group or project you want Glean to receive change events for. Group webhooks apply to all projects in a group and its subgroups; project webhooks apply to a single project.

  1. Go to the group or project → Settings → Webhooks → Add new webhook.
  2. Configure the webhook:
    • URL: copy the webhook URL shown on the GitLab connector setup page in the Glean Admin console.
    • Secret token: the webhook secret token you enter in Glean.
    • Trigger: enable:
      • Push events
      • Comments
      • Issues events
      • Confidential issues events
      • Merge request events
      • Wiki page events
      • Repository update events
  3. Select Add webhook.

3. Build the user-mapping file (optional)​

User OAuth maps each teammate's GitLab identity to their Glean account. You can also provide a CSV that maps numeric GitLab user IDs to company (SSO) emails as a fallback for teammates who haven't authorized GitLab. Existing CSV mappings remain supported.

  1. Create a CSV with two columns in the order user ID, email. Column headers are not required.
    • The user ID is the numeric id from the GitLab API — not the username. Retrieve IDs with the members API.
    • Example row:
      12345,user1@example.com
  2. Keep the file to upload during connector configuration. See Configure in Glean.

You can source company emails from your identity provider (for example, Okta or Google Workspace).

4. Choose an OAuth app​

Use Glean's managed GitLab OAuth app or your own app. Glean's managed app supports GitLab Cloud at gitlab.com, not GitLab Server.

Choose the app using the control shown in your setup:

  • If your setup form has Use Glean's GitLab OAuth app, keep it selected to use Glean's managed app. New Cloud setup forms select this checkbox by default. Clear it to use your own app.
  • If your setup has a Connect step, choose Central to use Glean's managed app. To use your own app, choose Custom. If only Central appears, click Set up a custom app instead.

With Glean's managed app, you don't need to create an OAuth app or supply its client ID and client secret. For existing connections, Glean loads the saved app choice and credentials. You don't need to replace an existing custom app to continue using the connector.

Create a custom OAuth app​

If you choose your own app, create a group-owned OAuth application:

  1. Open the GitLab Cloud connector setup in the Glean Admin console. For the single-form setup, open the setup instructions to copy the Callback URL. For setup with a Connect step, open Custom and copy both callback URLs shown there.
  2. In GitLab, go to your top-level group and open Settings → Applications. Click Add new application if shown.
  3. Enter a Name, such as Glean, and set Redirect URI to the callback URL from Glean. If your setup shows two callback URLs, enter both, each on its own line. Don't use the webhook URL.
  4. Select openid, profile, email, read_user, read_api, and mcp. Keep Confidential selected.
  5. Save the application. Copy GitLab's Application ID and Secret to enter as the client ID and client secret in Glean.

See Configure GitLab as an OAuth 2.0 authentication identity provider.

5. Configure in Glean​

Use the steps in this section if your GitLab Cloud setup form contains Use Glean's GitLab OAuth app.

Separate connection and indexing steps

If your setup has Connect and Set up indexing steps, use the unified setup guide instead. See GitLab Cloud unified setup.

1. Start connector setup​

In the Glean Admin console, go to Connectors, add the GitLab connector, and select the GitLab Cloud setup. Set the connector display Name and icon.

2. Enter the access token​

Paste the access token into the Access token field.

3. Enter the webhook secret token​

In the Webhook secret token field, enter the same secret token value you used when creating webhooks. This lets Glean verify that incoming webhook events came from your GitLab instance.

4. Set the token privilege checkboxes​

  • API token has owner privileges: select this if the token's account has the Owner role on the relevant groups. Clear it otherwise.
  • API token has write privileges: select this for automatic webhook creation if the token has the api scope or both Webhook: Read and Webhook: Create. Clear it for manual webhook setup. See Create webhooks manually.

5. Select the OAuth app​

Keep Use Glean's GitLab OAuth app selected to use Glean's managed app. Glean hides the client credential fields for this choice.

To use your own app, clear Use Glean's GitLab OAuth app. You must enter both the application's Client ID and Client Secret.

6. Upload the user-mapping file (optional)​

Upload the CSV if you want an identity-mapping fallback for teammates who haven't authorized GitLab. Glean validates the file if you upload one. See Build the user-mapping file.

7. Save and authorize​

Complete both setup actions:

  1. Click Save. Glean validates the connector configuration. If validation fails, fix the reported problem and save again.
  2. Click Authorize and complete the GitLab OAuth flow. Return to Glean and confirm that authorization succeeded.

Saving the configuration alone doesn't complete OAuth setup. After setup and crawling, results depend on the user's GitLab access and identity mapping. Teammates can authorize their own accounts using the user flow.

Glean always indexes project overviews, merge requests (with comments and diffs), code, issues, and wikis. These object types have no per-object toggles. Glean also indexes epics by default. To skip epics, clear Crawl Group Epics on the setup page. Glean makes code searchable through Code Search and turns Code Search on by default after setup.

Authorize GitLab as a user​

Users already mapped through a user-mapping CSV don't need user OAuth for search access. Users without an existing identity mapping can authorize GitLab instead of asking an admin to update the user-mapping CSV.

After an admin configures the connector with Glean's managed OAuth app or a custom app, teammates can connect their own GitLab accounts:

  1. In Glean, go to Settings → Connectors and open GitLab.
  2. Under Search access, click Authorize for the GitLab instance you want to connect.
  3. Click Get search results from GitLab. If Glean asks you to choose an instance, click Add to Glean beside that instance.
  4. Sign in to GitLab and complete authorization, then return to Glean.

Authorize each instance you need separately. If the authorization option isn't available, ask your Glean admin to check the connector's OAuth configuration.

OAuth links your identity but doesn't expand the connector's crawl scope or grant new GitLab permissions. Allow content and identity crawling to complete before checking results. Disconnecting OAuth isn't a way to revoke access to already indexed content. Manage access in GitLab.

Select code files to index​

In the connector's Manage data tab, under Additional Crawl Settings:

Use Code file types to index body to select supported file extensions or add custom extensions, such as .py or .md.

Use Code files to index body to enter an exact filename. This can be a file without an extension, such as Dockerfile, a file with an extension, such as skill.md, or a dot-prefixed filename, such as .gitignore. Glean matches the value with the repository file name after removing its directory path. To match every filename ending in .dockerfile, add .dockerfile under Code file types to index body. Enter multiple filenames as comma-separated values. Filename matching is case-insensitive.

These connector-level settings control code-body indexing and searchability for repositories in the groups and projects the token can reach. Code Search remains enabled by default after you connect the connector.

API endpoints reference​

Glean uses the following GitLab REST API endpoints to crawl content and identity data.

EndpointDescription
GET /api/v4/usersList users for identity crawling
GET /api/v4/groupsList groups the token can access
GET /api/v4/projectsList projects the token can access
GET /api/v4/projects/<id>/members/allList project members (permissions)
GET /api/v4/projects/<id>/wikisList and fetch wiki pages
GET /api/v4/projects/<id>/issuesList issues
GET /api/v4/projects/<id>/merge_requestsList merge requests
GET /api/v4/projects/<id>/merge_requests/<id>/notesList merge request comments
GET /api/v4/projects/<id>/merge_requests/<id>/diffsFetch merge request diffs
GET /api/v4/projects/<id>/repository/commitsFetch commit messages on the default branch