# GitLab accounts Give an agent managed accounts on one or more GitLab instances: a `glab` CLI and `git push` over HTTPS, both authenticated by operator-supplied access tokens, with no manual `glab auth login`. An agent can hold any number of accounts, each under a label you choose. Two labels can name two instances, such as `gitlab.com` and a self-hosted one. Provisioning needs no per-agent nix declaration and no rebuild: the agent fetches its tokens from the swarm secret store itself. ## Linking an account The swarm UI has no GitLab dialog yet, so link an account with the controller's API. This is the same route family as the other [linked accounts](../swarm/ui.md#linking-external-accounts): ```text PUT /api/hives/{hive}/agents/{agent}/gitlab-accounts/{label} {"url": "https://gitlab.example.org", "token": ""} ``` - `label` is lowercase letters, digits and hyphens. It names the account in the store and in the account list. - `url` is the instance's base URL. The host must be a DNS name: an IP address, `localhost` and a single-label name get a 400, because the agent reaches the instance through its hive's egress proxy, which takes names only. A port and a subfolder (`https://example.org:8443/gitlab`) are part of the address. The path may hold letters, digits and `. _ ~ / -`; a URL with user information, a query, a fragment or any other character gets a 400, so every stored account is one the agent uses. - A plain `http://` URL works, and then the token crosses the network in cleartext. Use `https://` unless the instance sits on a trusted network. - `token` is a GitLab personal, group or project access token. Scope it `api` and `write_repository`: `glab` needs the first, and `git push` over HTTPS needs the second. Use a dedicated bot account and the narrowest token that does the agent's work, because the agent has passwordless sudo and can act within the token's scopes. A label that holds an account already answers 409; delete it first (`DELETE .../gitlab-accounts/{label}`), then link again. No route hands a token back. `GET /api/hives/{hive}/agents/{agent}/linked-accounts` lists the account as kind `gitlab`, with its label and URL. Linking also allows the instance's host in the agent's egress, as a `link:gitlab: