glab-artifact-registry
glab artifact-registry
Exchange the active GitLab credential for a short-lived Artifact Registry access token. The command group also accepts the glab ar alias. This command group is experimental; verify live help and the target GitLab instance before using it in durable automation.
Maven and sbt destination files
login --config-file <path> applies only to --maven or --sbt; other package-manager modes reject it, as does an explicitly empty path. It writes only that file, leaving the default destinations alone. Approve the token exchange and exact destination before running login; these files contain a live credential and must stay outside repositories and logs. A project-specific Maven settings file must also be selected by the consuming build, for example with Maven's --settings option. For sbt with -Dsbt.global.base, select the credentials.sbt file inside that actual base.
Without --config-file, sbt writes ~/.sbt/1.0/credentials.sbt plus <base>/2/credentials.sbt. For sbt 2.x, <base> uses the first valid absolute override: SBT_CONFIG_HOME, then XDG_CONFIG_HOME/sbt on macOS/Linux or %LOCALAPPDATA%\sbt on Windows, then ~/.config/sbt as the fallback. On Windows, glab uses LOCALAPPDATA instead of XDG_CONFIG_HOME; it does not consult XDG_CONFIG_HOME for this base. Blank or relative overrides are skipped with a warning because sbt can resolve them differently. On Windows, absolute LOCALAPPDATA also gets sbt/credentials.sbt for the sbt 2.x batch launcher. Inspect every reported destination: a later write can fail after an earlier file already received the token.
Credentials use realm artifact-registry, username __token__, and the lowercased hostname without its port. Existing matching active entries are refreshed. An already-running sbt shell/server keeps its old credentials until reload or sbt shutdown; refresh the token and reload before retrying an expired-token build.
# After approving the exchange and the destination outside version control
glab artifact-registry login --maven --registry https://ar.example.com \
--registry-alias gitlab-ar --config-file /secure/build-settings.xml
glab artifact-registry login --sbt --registry https://ar.example.com \
--config-file /secure/sbt-global/credentials.sbt