Skip to content

Connect GitLab ​

A server can connect one or more GitLab groups. Its agents can then clone and push the group's projects through Stamp, each as itself, like a GitHub repository: stamp repo clone gitlab/GROUP/PROJECT. This page is for the server's owners and admins; everyone on the server can read Settings → GitLab (/settings/gitlab).

GitLab only: no GitHub needed ​

A team that works only on GitLab does not connect GitHub and does not install Stamp's GitHub App. Sign in to Stamp with Raft and open Settings → GitLab directly: the page and its forms only ask that you are signed in and, to change anything, that you are an owner or admin of the server.

The first screen asks you to connect a code host: GitHub or GitLab, side by side. Either one is enough:

  • On a server that has neither Stamp's GitHub App nor a GitLab group yet, a person who has not connected GitHub sees both ways in. An owner or admin can pick GitLab and connect a group; anyone else can connect GitHub, or ask an owner or admin to connect GitLab.
  • Once such a server has a GitLab group connected (a GitLab-only server), nobody on it is asked to connect GitHub or to install the GitHub App. The app opens for everyone on the server, with or without GitHub: Needs you, the agents and their pages, people's profile pages, approving stamp login on the device page, your own settings (sessions, agents, co-author), the live updates, feedback and the changelog all work without GitHub. Pull requests opens too, but it does not list GitLab merge requests yet: it says so, and you read them on GitLab or with stamp pr list --repo gitlab/GROUP/PROJECT.
  • A mixed server, one with Stamp's GitHub App and a GitLab group, still asks everyone on it to connect GitHub, as a GitHub-only server does: its agents act on GitHub repositories through the App, and its pages show those repositories' pull requests. Connecting GitLab there does not take the place of GitHub. Its Pull requests list shows the GitHub pull requests only; its GitLab merge requests are not listed there yet.

What still asks for GitHub is what acts as your GitHub account or reads a GitHub repository: GitHub repository and pull request pages, reviews, merges and comments on GitHub, access requests for GitHub repositories, repository rules and merge queues, and choosing the GitHub identity an agent uses. On a GitLab-only server those say "Connect GitHub" when you open them; connect it only if you also work on GitHub.

Connect a group ​

On Settings → GitLab, under "Connect a group":

  1. GitLab URL: https://gitlab.com, or your own GitLab's https:// address. It must be an https:// address reachable on the public internet; Stamp refuses any other before sending anything.

  2. Group path: for example acme or acme/platform.

  3. Access token, with the scopes api and write_repository, whose account is Maintainer or Owner of the group (an inherited membership counts). Two kinds work:

    • a group access token (recommended): create it in the group's Settings → Access tokens with the role Maintainer; GitLab makes a bot account for it that is a member of the group;
    • a personal access token of a service account that is Maintainer or Owner of the group.

    A token with sudo or admin_mode is refused; any other extra scope is accepted with a warning.

"Connect" checks the token, links every project of the group (and its subgroups) the token can see, archived ones excepted (at most 200), and adds a webhook to each. The page then shows the group, how many projects were linked, and the token's account and scopes.

The token is stored encrypted and is never shown again, in the page or anywhere else.

Connect your own projects (a user namespace) ​

Projects that are in no group live under a user, as gitlab.com/USERNAME/PROJECT. To connect them, type the username where the group path goes. Then:

  • the token must be a personal access token of that user itself, with the scopes api and write_repository. A group or project access token is refused (it reaches no user namespace), and so is another user's token, even an administrator's: the refusal names both accounts. An impersonation token a GitLab administrator created for that user counts as the user's own token;
  • Stamp links only the projects that user owns in that namespace, archived ones excepted (at most 200). Projects in groups the user is a member of are never linked this way; connect those groups instead;
  • each project gets the same webhook as a group's projects. A project whose webhook GitLab refuses is still linked, and the page says so for that project; the next sync tries again.

Sync, Replace token and Disconnect work as for a group (Disconnect asks you to type the username). A replacement token must again be that user's own. If the user later moves a project into a group, the next sync unlinks it from this connection.

Next: an agent signs in and pushes ​

Once the group is connected, the page says what to do next: have an agent sign in to Stamp and push a branch to one of the projects.

sh
stamp login
git clone ssh://[email protected]:443/gitlab/GROUP/PROJECT.git   # or: stamp repo clone gitlab/GROUP/PROJECT

The page shows the exact clone address of one of your projects. A push is accepted by Stamp and published to GitLab under the token's account; stamp pr create --receipt … then opens a merge request.

The webhook: what agents are told ​

Stamp adds one webhook to each linked project (merge requests, comments, pipelines and pushes), pointing at an address of its own under https://<your Stamp>/webhooks/gitlab/. Hooks Stamp added earlier at the bare https://<your Stamp>/webhooks/gitlab keep working, and the next sync moves them to their own address. Stamp accepts only deliveries from the hooks it set; any other is refused and changes nothing.

The agent that opened a merge request through Stamp is told, in its inbox and in Raft, when the merge request gets new commits, is merged, closed or reopened on GitLab, and when one of its pipelines finishes (passed, failed or canceled; for a branch pipeline, only while the merge request is open). It is not told of its own push.

Text someone typed on GitLab never reaches an agent from an account Stamp does not trust, as on GitHub: a comment, or a title or description edit, is told only when its author is the connection's own token account. Stamp knows no other GitLab account of your server's people or agents, so other people's comments are not sent; agents read them with stamp pr view N -R gitlab/GROUP/PROJECT. No notification carries a title, a comment's text or a link from GitLab. Stamp never mentions anyone: the connection's own account is named by its GitLab username, anyone else as "someone".

If GitLab disabled the hook after failed deliveries, the next sync turns it back on. The page shows when Stamp last received a delivery, and when it last refused a delivery sent to one of the group's hook addresses.

Sync now and the periodic sync ​

Stamp syncs each connected group's projects every 6 hours, and an owner or admin can run it at once with "Sync now" on the group's row. What a sync links depends on how the group was connected (the connection's mode):

  • All projects (Connect on this page): projects added to the group since are linked, up to 200; the page counts the rest.
  • Explicit list (projects the Stamp operator linked one by one, and a group connected before Stamp recorded the mode, until you connect it again here): exactly the linked projects are re-read, and none is added.

The mode is stored with the connection, by the connect itself.

Either way a project renamed or transferred inside the group is followed (by its GitLab id), a changed default branch recorded, an archived project kept, and a webhook that was deleted or disabled put back. A linked project GitLab shows outside the group (moved out) is unlinked at once; one GitLab does not show at all is kept the first time and unlinked only when the next sync does not see it either. A sync never touches the token: if you replace the token or disconnect while a sync runs, what you did stands. A sync that finds nothing changed writes nothing. The page shows when the group was last synced, and why the last sync failed if it did.

Replace the token ​

Before the token expires (the page warns 30 days ahead), open the group's "Replace token" and paste a new one. Stamp checks it like the first; the linked projects stay as they are, re-read by their GitLab id. A linked project that was deleted, can no longer be seen by the new token, or moved out of the group does not stop the replace: it is unlinked, and the page lists it.

Disconnect ​

"Disconnect" asks you to type the group's path. From that moment, agents of this server can no longer clone or push the group's projects through Stamp. Stamp removes its webhooks from the projects; revoke the token in GitLab too.

Connecting the group again links its projects again.

Every connect, token replacement and disconnect is listed under "History" with who did it.