# GitLab 与 Self-Hosted

> 配置 GitLab OAuth 应用、仓库同步与自托管网络，理解删除连接保留的内容。

- 网址：https://funcoding.ai/agents/cursor/integrations/gitlab/
- 核实日期：2026-10-18（命令、配置和价格以官方文档为准）
- 官方来源：[Cursor 官方文档：GitLab](https://cursor.com/docs/integrations/gitlab)

---
GitLab 集成支持 Cloud Agents 与 Bugbot。官方当前要求付费 GitLab Premium 或 Ultimate，因为依赖 project access tokens；不能把 GitLab Free 当作已支持的接入套餐。

## GitLab.com

需要 Cursor admin 和 GitLab maintainer。在 Dashboard > Integrations 连接 GitLab，完成授权后打开 Manage > Sync Repos，再为同步的仓库配置功能。Disconnect Account 用于断开账号。

## Self-Hosted 前提

Cursor 需 Teams 或 Enterprise，GitLab 实例管理员负责创建应用。实例需安全入站接受 Cursor API/Git 访问，并允许出站 webhook；入站 IP 按官方当前列表配置。

## 创建与注册应用

1. 在 GitLab 创建应用，官方优先建议 instance level。
2. Redirect URI 设为 `https://cursor.com/gitlab-connected`。
3. Trusted 和 Confidential 都设为 true，scopes 为 api、write_repository。
4. 保存 Application ID 与 Secret。
5. 在 Cursor Integrations > Advanced > GitLab Self-Hosted 填 hostname、ID 和 Secret，点击 Register。
6. 选择实例并 Connect，随后 Manage > Sync Repos。

若需私网，Enterprise 可与 Cursor 协调两种方式，细节见[私网连接](https://funcoding.ai/agents/cursor/cloud/private-connectivity/)。AWS PrivateLink 适合部署在 AWS 或能放在 AWS Network Load Balancer 后面的实例，可覆盖 Cursor 访问 GitLab，需要时也覆盖 GitLab 回发 webhook，不经公网，需要与 Cursor 协调并配置 AWS endpoint service。Cloudflare Tunnel 适合 PrivateLink 不便或只允许出站的环境：Cursor 创建并持有 tunnel，提供 hostname 和 token，你在自己网络里以出站方式运行 `cloudflared` 并负责维护，不需要 Cloudflare 账号或合同。

## 删除实例的实际影响

在 Advanced > GitLab Self-Hosted 的实例菜单选 Delete Instance，会移除 OAuth 凭据、webhook secret、服务账号/用户 token 和 Cursor 创建的 webhook。Bugbot 仓库设置、团队设置及 learned rules 会保留，重新连接相同 hostname 时恢复。

这与只断开个人账号不同。需要将 GitLab group/namespace 锁定到 Cursor 组织时使用 Protected Git Scopes，要求 GitLab Owner。
