GitLab connects with an access token rather than an app: you paste a token, Ankra shows you a webhook URL and secret, and you register the hook in GitLab yourself. GitLab.com and self-managed instances work the same way.
What a GitLab connection powers
- AI code review on merge requests, and replies when somebody mentions
@ankraaiin a merge request comment. - Ankra Pipelines runs on pushes, tags and merge requests. Cluster GitOps sync supports GitHub and Bitbucket Cloud only, so a cluster’s repository cannot live on GitLab.
ai.manage, turns it on. Git Providers compares what GitLab supports with GitHub and Bitbucket Cloud.
Prerequisites
You need:- A GitLab access token. A personal, group, or project access token all work.
- Permission to add a webhook to each project Ankra should watch, or to the group containing them.
- To switch on AI review or mention replies: the
ai.managepermission in Ankra, which the organisation owner and admin roles hold.
Token scopes
A group access token scoped to the group that owns your projects is usually the least fiddly choice: one token, one webhook per project, and it survives people leaving.
The Connect GitLab form in Ankra names only
read_api and read_repository. That is enough to connect and read, not to post reviews: give the token api as well.
Connect GitLab
1
Open the GitLab connection form
In Ankra, go to Ankra AI → Gateway connections (
/next/ai/settings/gateway) and scroll to the GitLab section. The Connect GitLab card is at its end.Integrations & alerts → Credentials → Add credential → GitLab opens the same form.2
Fill in the form
- Name - optional, and worth setting when you connect more than one instance.
- GitLab address - leave it empty for gitlab.com, or give the base URL of your self-managed instance, for example
https://gitlab.example.com. - Access token - the token from above.
3
Copy the webhook address and secret
The Copy the webhook secret now dialog shows the Webhook address, of the form
https://platform.ankra.app/webhooks/gitlab/<credential-id>, and the Webhook secret.The instance now has its own card in the GitLab section. Show settings on it shows the GitLab webhook address again, with the secret masked.4
Register the webhook in GitLab
In the GitLab project, go to Settings → Webhooks → Add new webhook:
- URL - the webhook URL you copied.
- Secret token - the secret you copied.
- Trigger - tick Merge request events, Comments, Push events, and Tag push events.
200 means Ankra accepted the delivery.Repeat per project, or add the hook once at group level under Settings → Webhooks to cover every project in the group.5
Turn on what you want
A fresh connection does nothing. On the instance’s card, click Show settings, then under Repositories switch on AI review and Replies to mentions on the All repositories row, or click Add rule for one project. See AI code review for what each switch does.
Which events do what
Every delivery is authenticated by comparing the
X-Gitlab-Token header against the credential’s stored secret. A delivery with the wrong secret is rejected with 401; an event kind Ankra does not use is answered 200 so GitLab keeps the hook enabled.
Rotate the webhook secret
On the instance’s card in Ankra AI → Gateway connections, click Show settings, then Regenerate the secret under GitLab webhook, and confirm with Regenerate secret. Ankra shows the new secret once, in Copy the webhook secret now.Repository paths and subgroups
Repository rules key on the project’s full path, lowercased, including every subgroup -my-group/my-subgroup/my-project. Up to 20 levels of nesting are supported. The path is what appears in the project’s URL after the instance host.
Disconnect
Disconnect on the instance’s card in Ankra AI → Gateway connections removes it, after you confirm. AI reviews, mention replies, and pipeline triggers through that credential all stop, and the webhook deliveries start being rejected. Remove the hook in GitLab too, so it stops retrying.Troubleshooting
Related
- Git Providers - what works on GitHub, GitLab and Bitbucket Cloud
- AI code review - the switches, the review, and the mention lane
- GitOps - how cluster configuration is stored and synced (GitHub and Bitbucket Cloud)
- Git credentials - where connected source-control credentials are listed
- GitLab CI/CD pipeline - building and publishing an application from GitLab CI