Integrations

GitLab

An instance may serve a product whose code lives on a self-hosted GitLab. GAOS then reads its merge requests and reviews them exactly as it does a GitHub pull request, with one difference that matters: on GitLab the review is advisory. It never blocks, approves or merges (D-114, design docs/designs/gitlab-forge.md). The names on this page are invented: gitlab.example.com and acme/route-api.

What works on GitLab

Agent or flowOn GitLab
ReviewerYes. A note, or an unresolved thread for a medium or worse finding.
Triager, test planner, e2e cardsYes: they read the merge request, its files and its code.
Fixer and automation plannerYes, with the GitLab write token (v0.80.0, D-115): a draft merge request on a gaos/fix- or gaos/catalog- branch, never into a CI file. See auto-fix settings.
Unit-test watcherYes, with the source GitLab pipeline (v0.82.0, D-117): the job you name, in the newest pipeline that ran the merge request’s last head commit. See Unit tests.
Revision loopNo. A GitLab review event does not start it.

The settings

SettingWhat it holds
GAOS_GITLAB_HOSTThe one GitLab host, a bare name such as gitlab.example.com: no scheme, no port, no path. Empty turns GitLab off.
GAOS_GITLAB_TOKEN_FILEThe review token’s file, mode 600: a glpat- project access token, role Reporter, scope api. Deploy, trigger, runner, job, GitHub, Brain Town and GAOS credentials are refused.
GAOS_GITLAB_WRITE_TOKEN_FILEThe write token’s file, mode 600: a glpat- project access token of its own, role Developer, scope api. One token in both files is refused. Empty leaves GitLab writes off. Its calls are traced as gitlab-write.
GAOS_GITLAB_CA_FILEAn optional PEM bundle for a private certificate authority. Empty means the system roots. TLS verification cannot be turned off.
BRAIN_TOWN_CONSUMER_KINDSMust include gitlab for GitLab events to reach GAOS.

In the production stack the three files are deploy/stacks/prod.pr-gitlab-token, deploy/stacks/prod.pr-gitlab-write-token and deploy/stacks/prod.pr-gitlab-ca.pem. The deploy creates any of them empty when it is absent, so an instance with no GitLab deploys unchanged. The clients start only on GitLab 15.7 or later, follow no redirect and send their token to the configured host alone; each token’s expiry is logged at start.

The repository entry and its pin

A GitLab repository is written with its host, for example gitlab.example.com/acme/route-api; nested groups are allowed. The first time GAOS needs it, it resolves the path to its project id and pins that id on every product that lists the entry. If the path later names another project — a rename or a transfer — the entry is refused (project-id-changed) until an auto-fix admin unlinks the entry and links it again from the product page, which pins the new id (D-127). A project the token cannot read is refused as token-cannot-read. A project access token reads one project; a group access token serves a group’s projects with no change in GAOS.

The advisory review

Text GAOS sends to GitLab

GitLab runs quick actions written in a note or a description, such as a line /approve. Review text is written by a model from content anyone can steer, so every body GAOS sends passes through one neutraliser first: a line that starts with / gets an empty code span in front of it, every @ mention is written as an entity, and a closing keyword such as Closes #1 gets a zero-width space before its reference. The text still reads the same.

The Brain Town frame

A GitLab merge-request event reaches GAOS through the Brain Town reader. GAOS takes it only when the frame carries data.gitlab — the host, the full path and the project id, which Brain Town takes from the integration’s own instance — and the host and path name a repository a product lists. The project id must be the pinned one. A frame without the three fields is skipped as gitlab-frame-incomplete; the owner and name fields of the frame are never used for GitLab. See the Brain Town reader.

Unit tests from a GitLab pipeline

A merge that is pushed with -o ci.skip has no pipeline, so GAOS does not test the merge commit. It reads the newest pipeline that ran the merge request’s last head commit: the branch pipeline, or the merge request pipeline if the project runs only those. Both test the same tree. The branch is tested before the merge, so a conflict that only the merge produces is not seen.

Troubleshooting

You seeWhy, and what to do
Disabled on the Integrations viewGAOS_GITLAB_HOST is not set.
Unusable: GitLab older than 15.7Upgrade GitLab; the merge-request diffs need 15.7.
Unusable: the token fileThe file is missing, empty, not mode 600, or holds another kind of token.
A merge request plans nothingThe repository is not listed, the reader’s kinds lack gitlab, the frame has no data.gitlab, or the project id does not match the pin.
project-id-changed in the logThe path now names another project. Check it; then unlink the entry and link it again from the product’s Repositories block.