Skip to content

GitLab

Connect Code Search to GitLab.com to index your GitLab repositories.

  • A GitLab.com account
  • Access to repositories you want to index
  • A Personal Access Token
  1. Go to GitLab.com → User Settings → Access Tokens

  2. Create a new token:

    • Name: Code Search
    • Expiration date: Choose based on your needs
    • Scopes: Select read_api and read_repository
  3. Click Create personal access token

  4. Copy the token immediately - it won’t be shown again!

  1. Go to ConnectionsAdd Connection
  2. Fill in:
    • Name: GitLab
    • Type: GitLab
    • URL: https://gitlab.com
    • Token: Your Personal Access Token
  3. Click Test Connection
  4. Click Create
Terminal window
curl -X POST "http://localhost:8080/api/v1/connections" \
-H "Content-Type: application/json" \
-d '{
"name": "GitLab",
"type": "gitlab",
"url": "https://gitlab.com",
"token": "glpat-xxxxxxxxxxxx"
}'

Add code hosts to your config.yaml:

codehosts:
# The key is the connection name
gitlab:
type: gitlab
url: "https://gitlab.com"
token: "$CS_GITLAB_TOKEN" # Environment variable reference
exclude_archived: true # Skip archived repos during sync

With environment variable:

Terminal window
export CS_GITLAB_TOKEN="glpat-xxxxxxxxxxxx"
ScopePurpose
read_apiRead access to the API
read_repositoryClone repositories
ScopePurpose
apiFull API access (for future MR creation)
read_userRead user information

After adding the connection:

  1. Click Sync on the connection card
  2. Code Search discovers your repositories
  3. Repositories are queued for indexing

Code Search discovers:

  • Personal projects you own
  • Projects you’re a member of
  • Group projects you have access to

You can exclude archived repositories:

codehosts:
gitlab:
type: gitlab
url: "https://gitlab.com"
token: "$CS_GITLAB_TOKEN"
exclude_archived: true # Skip archived repos during sync

Your personal projects are under your username:

  • username/project-name

Group projects follow the group path:

  • group-name/project-name
  • group-name/subgroup/project-name
LevelDescription
PrivateOnly visible to project members
InternalVisible to logged-in GitLab users
PublicVisible to everyone

Code Search can index all projects your token has access to.

GitLab.com rate limits:

TypeLimit
Authenticated requests2,000 requests/minute
Git operations300 operations/minute

Code Search respects these limits and will automatically throttle requests.

401 Unauthorized
  • Verify the token is correct
  • Check the token hasn’t expired
  • Ensure required scopes are selected
404 Project Not Found
  • Verify you have access to the project
  • Check the token has read_api scope
  • Ensure the project exists and isn’t deleted
remote: HTTP Basic: Access denied
  • Verify read_repository scope is selected
  • For subgroups, ensure you have access to the parent group
429 Too Many Requests
  • Wait for the rate limit to reset
  • Check the RateLimit-Reset header for reset time
  • Reduce sync frequency if this happens often