GitLab Integration
Connect Codeveira to GitLab — whether you use GitLab.com or a self-hosted instance. This guide walks through creating an access token, adding your first repository, configuring a webhook for automatic code reviews, and optionally enabling OAuth single sign-on.
Prerequisites
- A GitLab instance — GitLab.com or self-hosted (GitLab CE/EE)
- A personal access token with
apiscope (created in Step 1) - Admin access to your Codeveira instance
How Codeveira integrates with GitLab
Codeveira connects to GitLab in two complementary ways: a read-only API connection to fetch commit data, and a webhook to receive push notifications in real time.
Read-only API access
The personal access token you create in Step 1 gives Codeveira access to the GitLab REST API v4. Every API call Codeveira makes is read-only — it never pushes to branches, creates merge requests, modifies labels, or changes anything in your GitLab project. Specifically, Codeveira uses the API to:
- Fetch commit metadata: author name, email, message, timestamp and parent SHA
- Download the unified diff for each commit to display in the review UI
- Retrieve repository information: default branch, description, visibility
- Request raw file content for inline syntax highlighting
The api scope is the minimum scope that covers all these read operations across both GitLab.com and self-hosted instances. If GitLab introduces a finer-grained read_repository scope for all endpoints Codeveira needs, a future release will document the narrower scope.
Automatic review creation via webhooks
The webhook you configure in Step 3 tells GitLab to send an HTTP POST to /webhooks/gitlab on every push. When Codeveira receives a valid push event it:
- Verifies the HMAC signature using the
X-Gitlab-Tokenheader against yourWEBHOOK_SECRET - Extracts the list of commits from the push payload
- Groups commits by author (consecutive commits by the same author are grouped into one review)
- Creates a code review for each group and fetches the full diff via the API
- Sends email notifications to any assigned reviewers
- Triggers the AI reviewer bot (if one is configured for this repository) to analyze the diff and post inline comments
Branch filtering
By default Codeveira creates a review for every push to every branch. You can limit this in Codeveira → repository settings → Branch filter — enter a glob pattern such as main or release/* and only pushes to matching branches will create reviews.
Create a GitLab access token
Codeveira uses a GitLab personal access token to fetch commits and diffs via the GitLab API.
- Sign in to GitLab and click your avatar in the top-right corner
- Choose Edit profile
- In the left sidebar, click Access tokens
- Click Add new token
- Fill in the fields:
- Token name:
Codeveira - Expiration date: choose a date that suits your rotation policy
- Select scopes: check
api
- Token name:
- Click Create personal access token
- Copy the token — it is shown only once
Add the repository in Codeveira
In Codeveira, go to Repositories → New Repository and click the GitLab button at the top of the form. Fill in the following fields:
- Name — display name for the repository inside Codeveira
- GitLab Project ID — found in your GitLab project under Settings → General (shown at the top as "Project ID")
- GitLab Path — the namespace and project slug, e.g.
mygroup/myrepo - GitLab URL — base URL of your GitLab instance, e.g.
https://gitlab.example.com. Optional if theGITLAB_URLenvironment variable is already set in your.env - Access Token — the personal access token you created in Step 1
GITLAB_URL environment variable for this repository only, which is useful when you connect repositories from multiple GitLab instances.
Click Save. Codeveira will immediately test the connection by fetching the project metadata. If the token or project ID is wrong you will see an error at this point.
Configure the webhook
A webhook tells GitLab to notify Codeveira on every push so that code reviews are created automatically.
- In your GitLab project, go to Settings → Webhooks
- Click Add new webhook
- Set the URL to:
https://codeveira.yourdomain.com/webhooks/gitlab
- Set the Secret token to the value of
WEBHOOK_SECRETfrom your.envfile - Under Trigger, check Push events only
- Enable SSL verification if your Codeveira instance is served over HTTPS (recommended)
- Click Add webhook
OAuth login (optional)
Enabling OAuth lets your team sign in to Codeveira with their GitLab credentials using the Sign in with GitLab button — no separate password required.
- In GitLab, go to Admin area → Applications → New application (requires GitLab admin rights)
- Fill in:
- Name:
Codeveira - Redirect URI:
https://codeveira.yourdomain.com/users/auth/gitlab/callback - Scopes: check
read_userandopenid
- Name:
- Click Save application
- Copy the Application ID and the Secret
- Add them to your
.env:GITLAB_APP_ID=your_application_id GITLAB_APP_SECRET=your_application_secret
- Restart Codeveira:
docker compose restart app
The Sign in with GitLab button will appear on the login page after the restart.
Troubleshooting
"401 Unauthorized"
The token is expired or was created with the wrong scope. Re-create the token in GitLab → Access tokens and make sure the api scope is checked. Update the token in Codeveira → repository settings.
"Project not found"
Either the GitLab Project ID is wrong, or the token belongs to a user who does not have access to that project. Verify the project ID in GitLab → Settings → General. Check membership under GitLab → project → Settings → Members.
Webhook not triggering
Check GitLab → Settings → Webhooks → Recent deliveries for the failed request and its response code. Common causes:
- The Codeveira URL is not reachable from your GitLab instance (network/firewall issue)
- The
WEBHOOK_SECRETin.envdoes not match the secret token configured in GitLab — they must be identical - SSL verification is enabled in GitLab but Codeveira does not have a valid certificate — either fix the certificate or disable SSL verification in the webhook settings