GitLab
Connect Code Search to GitLab.com to index your GitLab repositories.
Prerequisites
Section titled “Prerequisites”- A GitLab.com account
- Access to repositories you want to index
- A Personal Access Token
Creating a Personal Access Token
Section titled “Creating a Personal Access Token”-
Create a new token:
- Name:
Code Search - Expiration date: Choose based on your needs
- Scopes: Select
read_apiandread_repository
- Name:
-
Click Create personal access token
-
Copy the token immediately - it won’t be shown again!
Adding the Connection
Section titled “Adding the Connection”Via Web UI
Section titled “Via Web UI”- Go to Connections → Add Connection
- Fill in:
- Name:
GitLab - Type:
GitLab - URL:
https://gitlab.com - Token: Your Personal Access Token
- Name:
- Click Test Connection
- Click Create
Via API
Section titled “Via API”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" }'Via Configuration File
Section titled “Via Configuration File”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 syncWith environment variable:
export CS_GITLAB_TOKEN="glpat-xxxxxxxxxxxx"Token Scopes
Section titled “Token Scopes”Minimum Required Scopes
Section titled “Minimum Required Scopes”| Scope | Purpose |
|---|---|
read_api | Read access to the API |
read_repository | Clone repositories |
Optional Scopes
Section titled “Optional Scopes”| Scope | Purpose |
|---|---|
api | Full API access (for future MR creation) |
read_user | Read user information |
Syncing Repositories
Section titled “Syncing Repositories”After adding the connection:
- Click Sync on the connection card
- Code Search discovers your repositories
- Repositories are queued for indexing
Repository Discovery
Section titled “Repository Discovery”Code Search discovers:
- Personal projects you own
- Projects you’re a member of
- Group projects you have access to
Filtering Repositories
Section titled “Filtering Repositories”You can exclude archived repositories:
codehosts: gitlab: type: gitlab url: "https://gitlab.com" token: "$CS_GITLAB_TOKEN" exclude_archived: true # Skip archived repos during syncGitLab Groups
Section titled “GitLab Groups”Personal Namespace
Section titled “Personal Namespace”Your personal projects are under your username:
username/project-name
Group Projects
Section titled “Group Projects”Group projects follow the group path:
group-name/project-namegroup-name/subgroup/project-name
Visibility Levels
Section titled “Visibility Levels”| Level | Description |
|---|---|
| Private | Only visible to project members |
| Internal | Visible to logged-in GitLab users |
| Public | Visible to everyone |
Code Search can index all projects your token has access to.
Rate Limits
Section titled “Rate Limits”GitLab.com rate limits:
| Type | Limit |
|---|---|
| Authenticated requests | 2,000 requests/minute |
| Git operations | 300 operations/minute |
Code Search respects these limits and will automatically throttle requests.
Troubleshooting
Section titled “Troubleshooting”Authentication failed
Section titled “Authentication failed”401 Unauthorized- Verify the token is correct
- Check the token hasn’t expired
- Ensure required scopes are selected
Repository not found
Section titled “Repository not found”404 Project Not Found- Verify you have access to the project
- Check the token has
read_apiscope - Ensure the project exists and isn’t deleted
Clone failed
Section titled “Clone failed”remote: HTTP Basic: Access denied- Verify
read_repositoryscope is selected - For subgroups, ensure you have access to the parent group
Rate limit exceeded
Section titled “Rate limit exceeded”429 Too Many Requests- Wait for the rate limit to reset
- Check the
RateLimit-Resetheader for reset time - Reduce sync frequency if this happens often
Next Steps
Section titled “Next Steps”- GitLab Self-Hosted - For self-hosted GitLab
- Repositories - Managing synced repositories