关于 gitlab
通过 `orbit` 命令行管理 GitLab 的技能,适用于 GitLab Cloud 和自托管实例。涵盖项目、合并请求、CI/CD 等资源,并支持配置档案和密钥解析。
主要功能
- 01管理项目、群组和成员
- 02处理合并请求与议题
- 03查看流水线和计划任务
- 04管理分支、标签和提交
- 05选择配置档案并解析密钥
适用场景
- 01审查合并请求及其流水线
- 02查找议题或项目成员
- 03创建或运行流水线计划任务
- 04通过 `orbit` 使用自托管 GitLab
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ jorgemuza/ orbit --skill gitlab安装后在 Claude Code 中输入/gitlab确认已加载。
附带文件references/commands.md
详细介绍
使用 orbit CLI 管理 GitLab
通过 orbit CLI 管理 GitLab 项目、合并请求、流水线、流水线计划、议题、分支、标签、提交、成员和用户。支持 GitLab Cloud 和通过 REST API v4 接入的自托管实例,并支持多配置文件及 1Password 密钥解析。
前提条件
- 已安装
orbitCLI — 如果运行which orbit失败,请使用以下方式安装:- macOS/Linux(Homebrew):
brew install jorgemuza/tap/orbit - macOS/Linux(脚本):
curl -sSfL https://raw.githubusercontent.com/jorgemuza/orbit/main/install.sh | sh - Windows(Scoop):
scoop bucket add jorgemuza https://github.com/jorgemuza/scoop-bucket && scoop install orbit
- macOS/Linux(Homebrew):
- 在
~/.config/orbit/config.yaml中配置了gitlab服务的配置文件 - 有效的凭据(个人访问令牌或 Bearer 令牌)——可存储为 1Password(
op://)或 Infisical(infisical://)引用
快速参考
所有命令均遵循以下格式:orbit -p <profile> gitlab <command> [flags]
别名:orbit -p <profile> gl <command> [flags]
所有命令均支持使用 -o json 输出 JSON。完整的命令详情和所有标志请参阅 references/commands.md。
对于使用自签名证书的自托管实例,请在服务配置中添加 tls_skip_verify: true。如需通过代理访问,请添加 proxy: socks5://host:port(也支持 http:// 和 https://)。
项目标识
可通过数字 ID 或完整路径引用项目:
orbit -p myprofile gl project 595orbit -p myprofile gl project schools/frontend/my-app
群组也接受 ID 或完整路径:schools/frontend
核心工作流
浏览项目和群组
# View project details
orbit -p myprofile gl project schools/frontend/my-app
# List your projects (membership-based)
orbit -p myprofile gl project list --search frontend
# Edit project settings (default branch, visibility, description)
orbit -p myprofile gl project edit 595 --default-branch main
orbit -p myprofile gl project edit 595 --visibility private
orbit -p myprofile gl project edit 595 --archived
# List all projects in a group (includes subgroups)
orbit -p myprofile gl project list --group schools/frontend
# Projects with activity today (shows branches)
orbit -p myprofile gl project activity
# Activity in the last 7 days, filtered by branch
orbit -p myprofile gl project activity --days 7 --branch development,master
# View group info
orbit -p myprofile gl group view schools/frontend
# List subgroups
orbit -p myprofile gl group subgroups schools
处理合并请求
GitLab 将其称为“合并请求”(MR),相当于 GitHub 的“拉取请求”(PR)。
# List open MRs
orbit -p myprofile gl mr list 595
# List merged MRs
orbit -p myprofile gl mr list 595 --state merged
# View MR details (shows source/target branch, conflicts, review status)
orbit -p myprofile gl mr view 595 42
# Create an MR
orbit -p myprofile gl mr create 595 \
--source feature/login --target main --title "Add login page"
# Merge an MR (with optional squash)
orbit -p myprofile gl mr merge 595 42 --squash
# Approve / unapprove
orbit -p myprofile gl mr approve 595 42
orbit -p myprofile gl mr unapprove 595 42
# Check approval status
orbit -p myprofile gl mr approvals 595 42
# Rebase onto target branch
orbit -p myprofile gl mr rebase 595 42
# Close / reopen
orbit -p myprofile gl mr close 595 42
orbit -p myprofile gl mr reopen 595 42
# Edit MR (title, description, assignee, labels, draft)
orbit -p myprofile gl mr edit 595 42 --title "Updated title"
orbit -p myprofile gl mr edit 595 42 --assignee 15 --labels "bug,urgent"
# Add a comment
orbit -p myprofile gl mr comment 595 42 --body "LGTM!"
# List discussion comments (excludes system notes)
orbit -p myprofile gl mr notes 595 42
CI/CD 流水线
# List recent pipelines
orbit -p myprofile gl pipeline list 595
# Filter by branch and status
orbit -p myprofile gl pipeline list 595 --ref main --status failed
# View pipeline details
orbit -p myprofile gl pipeline view 595 12345
# List jobs in a pipeline (shows stage, status, duration)
orbit -p myprofile gl pipeline jobs 595 12345
# Retry a failed pipeline
orbit -p myprofile gl pipeline retry 595 12345
# Cancel a running pipeline
orbit -p myprofile gl pipeline cancel 595 12345
流水线别名:pipeline、pipe、ci — 因此也可以使用 orbit gl ci list 595。
列出流水线计划
orbit -p myprofile gl schedule list 595
创建夜间计划
orbit -p myprofile gl schedule create 595 --desc "Nightly build" --ref main --cron "0 2 * * *"
立即触发计划
orbit -p myprofile gl schedule run 595 42
更新计划的 cron 表达式或停用计划
orbit -p myprofile gl schedule update 595 42 --cron "0 3 * * *" orbit -p myprofile gl schedule update 595 42 --active=false
添加/移除计划变量
orbit -p myprofile gl schedule var 595 42 DEPLOY_ENV production orbit -p myprofile gl schedule var-delete 595 42 DEPLOY_ENV
删除计划
orbit -p myprofile gl schedule delete 595 42
计划别名:schedule、sched。
分支和标签
# List branches
orbit -p myprofile gl branch list 595 --search feature
# View branch details (includes latest commit)
orbit -p myprofile gl branch view 595 main
# Create a branch from a ref
orbit -p myprofile gl branch create 595 feature/new-thing main
# Delete a branch
orbit -p myprofile gl branch delete 595 feature/old-thing
# Protect a branch (only maintainers can merge, no direct push)
orbit -p myprofile gl branch protect 650 main --push no-access --merge maintainer
# List protected branches
orbit -p myprofile gl branch protections 650
# Remove protection
orbit -p myprofile gl branch unprotect 650 main
# List tags
orbit -p myprofile gl tag list 595
# Create an annotated tag
orbit -p myprofile gl tag create 595 v1.0.0 main -m "Release v1.0.0"
提交
# List recent commits (default branch)
orbit -p myprofile gl commit list 595
# List commits on a specific branch
orbit -p myprofile gl commit list 595 --ref feature/login
# View commit details
orbit -p myprofile gl commit view 595 abc1234
议题
# List open issues
orbit -p myprofile gl issue list 595 --state opened
# Filter by labels
orbit -p myprofile gl issue list 595 --labels bug,urgent
# View issue details
orbit -p myprofile gl issue view 595 1
# Create an issue
orbit -p myprofile gl issue create 595 --title "Fix login bug" --labels bug,urgent
# Close an issue
orbit -p myprofile gl issue close 595 1
成员和用户
# List project members (shows access level: Guest/Reporter/Developer/Maintainer/Owner)
orbit -p myprofile gl member list 595
# Show current authenticated user
orbit -p myprofile gl user me
# Search users
orbit -p myprofile gl user list --search john
常见用法
获取用于脚本处理的 JSON:
任何命令均支持使用 -o json 输出机器可读的数据:
orbit -p myprofile gl mr list 595 -o json | jq '.[].title'
检查分支的 CI 状态:
orbit -p myprofile gl pipeline list 595 --ref main --limit 1
查找项目的参与者:
orbit -p myprofile gl member list 595
端到端审查 MR:
# View MR details
orbit -p myprofile gl mr view 595 42
# Check its pipeline
orbit -p myprofile gl pipeline list 595 --ref feature/login --limit 1
# Read discussion
orbit -p myprofile gl mr notes 595 42
# Approve with comment
orbit -p myprofile gl mr comment 595 42 --body "Approved, looks good"
重要说明
- 必须指定配置文件 — 始终传入
-p <profile>以选择 GitLab 连接。配置文件必须配置类型为gitlab的服务。 - 服务标志 — 如果配置文件中有多个 GitLab 服务,请使用
--service <name>进行区分。 - Cloud 与自托管 — 两者均支持。配置文件中的基础 URL 决定 GitLab 实例。
- 密钥引用 — 配置中的凭据可使用 1Password(
op://vault/item/field)或 Infisical(infisical://<env>/<path>/<KEY>)引用,并在运行时解析。运行一次orbit auth即可解析并缓存所有密钥(使用 1Password 时只需进行一次生物识别验证)。使用orbit auth clear清除缓存。请参阅密钥。 - MR = PR — 在 GitLab 语境中,如果用户说“拉取请求”或“PR”,指的就是合并请求。
- 分页 — 大多数列表命令默认返回 20-50 条结果。使用
--limit N调整数量。