Skip to main content

GitLab Integration

Connect GitLab to enable agents to access code, merge requests, and CI/CD pipeline information during investigations and remediation runs.

Used by: Incident Response, Vulnerability Remediation, AI Coding Cost Efficiency, and your own agents.

Capabilities​

Once connected, agents can:

CapabilityDescription
Browse CodeView repository files
Merge RequestsReview MRs and changes
PipelinesCheck CI/CD pipeline status
CommitsView commit history
IssuesAccess issue tracking
note

This integration has write tools: create branches, commit file changes, open and merge merge requests, and create repositories. These tools are available to an agent unless its tool filters exclude them. They also need a token with the api scope. A governance policy on write operations pauses each write for a person to approve. Every call is recorded in the Audit Trail.

How GitLab organizes projects​

A GitLab project is one Git repository, with its merge requests, pipelines and issues. A group holds projects and other groups (subgroups), to any depth. A top-level group is like a GitHub organization. GitLab shows these levels in the path of a URL, with a / between levels:

URLPathWhat it is
https://gitlab.your-company.com/platformplatformThe top-level group platform
https://gitlab.your-company.com/platform/paymentsplatform/paymentsThe subgroup payments in the group platform
https://gitlab.your-company.com/platform/payments/apiplatform/payments/apiThe project api in the subgroup payments

A path has no marker that tells a group from a project. Open the URL in GitLab to see which it is.

Prerequisites​

  • A GitLab account on GitLab.com or on a self-hosted GitLab
  • An access token. The token controls which projects Autoheal can see.
TokenAutoheal can seeUse it when
Group access tokenThe projects of one group, its subgroups, and projects shared with the groupYou connect one group. Recommended. You must have the Owner role in the group to create it.
Personal access tokenAll projects that the user can seeYou cannot create a group access token. Group limits the sync to one group.
Project access tokenOne projectYou connect one project. Set Group to the group that contains the project.

Setup​

  1. Create an access token

    Group access token (GitLab docs):

    1. In GitLab, open the group. Go to Settings → Access tokens
    2. Click Add new token
    3. Enter a token name (e.g., "Autoheal Integration") and an expiration date
    4. Select the role Reporter. For the write tools, select Developer
    5. Select scopes: read_api, read_repository
    6. Create the token. Then copy it

    Personal access token (GitLab docs):

    1. In GitLab, select your avatar. Go to Edit profile → Access tokens
    2. Click Add new token
    3. Enter a token name and an expiration date
    4. Select scopes: read_api, read_repository
    5. Create the token. Then copy it
  2. Add Integration in Autoheal
    1. Go to Integrations in Autoheal
    2. Click GitLab
    3. Enter a name (e.g., "GitLab platform group")
  3. Configure Credentials

    Enter the following:

    • GitLab Hostname: The host name only, such as gitlab.com or gitlab.your-company.com. Do not enter https:// or a path
    • Group: The path of the group to sync, from the group's URL. For https://gitlab.your-company.com/platform/payments, enter platform/payments. Enter a group, not a project
    • Private Token: Your GitLab access token
  4. Test and Save

    Click Test Connection to check the connection. Then click Save.

Required Scopes​

ScopeWhy It's Needed
read_apiAccess GitLab API endpoints
read_repositoryView repository contents and clone repositories

Repositories in the Context Graph​

When you save the integration, Autoheal adds projects to the Context Graph as repositories. Autoheal syncs them again every day, and each time you change the integration.

Autoheal syncs each project of the group, of all its subgroups at all levels, and the projects shared with the group, if the token can see them. Each project becomes one repository with the project's full path as its name. Groups and subgroups do not become entries. For example, with Group set to platform:

GitLabIn the Context Graph
Group platformNo entry
Project platform/webRepository platform/web
Subgroup platform/paymentsNo entry
Project platform/payments/apiRepository platform/payments/api
Project platform/payments/ledger/coreRepository platform/payments/ledger/core
Project security/scanner, shared with platformRepository security/scanner

To sync more than one top-level group, add one GitLab integration for each group. Agents find these repositories by name, such as platform/payments/api, and clone them with the token of the integration that synced them.

Self-Hosted GitLab​

  • Autoheal calls https://<hostname>/api/v4 and clones over HTTPS. Make sure that your Autoheal installation can connect to the host on port 443.
  • GitLab must be at the root of its host. A GitLab at a path, such as https://your-company.com/gitlab, is not supported.
  • If your own certificate authority (CA) signs the GitLab certificate, add that CA to your Autoheal installation as a custom root CA. If you do not, connections fail with certificate signed by unknown authority.

Example Queries​

What pipelines failed in the last 24 hours?
Show me the latest merge requests for the backend project
What commits were deployed yesterday?

Troubleshooting​

401 Unauthorized
  • Check that the token is correct and not expired
  • Check that required scopes are granted
Connection Failed (Self-Hosted)
  • Check that the GitLab hostname is correct
  • Check network/firewall accessibility
  • For certificate signed by unknown authority, add your CA to your Autoheal installation as a custom root CA
Repositories Missing from the Context Graph
  • Check that Group is the path of a group, such as platform/payments, not its display name, its URL or a project path. A path that is not a group fails the sync with 404 Group Not Found
  • Check that the token can see the projects. A group access token sees only its own group
  • Check that the token has the read_api scope