bkt
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBitbucket CLI (bkt)
Bitbucket CLI(bkt)
bktghbktghDependency Check
依赖检查
Before executing any command, verify the CLI is installed:
bktbash
bkt --versionIf the command fails or is not found, install it using one of these methods:
bkt| Platform | Command |
|---|---|
| macOS/Linux | |
| Windows | |
| Go | |
| Binary | Download from GitHub Releases |
Only proceed with commands after confirming installation succeeds.
bkt在执行任何命令之前,请确认CLI已安装:
bktbash
bkt --version如果命令执行失败或未找到,请通过以下方式之一安装:
bkt| 平台 | 命令 |
|---|---|
| macOS/Linux | |
| Windows | |
| Go | |
| 二进制包 | 从GitHub Releases下载 |
确认安装成功后,再执行命令。
bktAuthentication
身份验证
bash
undefinedbash
undefinedData Center (opens browser for PAT creation)
Data Center(打开浏览器创建PAT)
bkt auth login https://bitbucket.example.com --web
bkt auth login https://bitbucket.example.com --web
Data Center (direct)
Data Center(直接方式)
bkt auth login https://bitbucket.example.com --username alice --token <PAT>
bkt auth login https://bitbucket.example.com --username alice --token <PAT>
Bitbucket Cloud
Bitbucket Cloud
bkt auth login https://bitbucket.org --kind cloud --web
bkt auth login https://bitbucket.org --kind cloud --web
Check auth status
检查身份验证状态
bkt auth status
**Bitbucket Cloud Token Requirements:**
- Create an "API token with scopes" (not a general API token)
- Select **Bitbucket** as the application
- Required scope: **Account: Read** (`read:user:bitbucket`)
- Additional scopes as needed: Repositories, Pull requests, Issuesbkt auth status
**Bitbucket Cloud令牌要求:**
- 创建“带权限范围的API令牌”(而非通用API令牌)
- 选择**Bitbucket**作为应用
- 必需权限范围:**账号:读取**(`read:user:bitbucket`)
- 根据需要添加额外权限范围:仓库、拉取请求、问题Contexts
上下文管理
Contexts store host, project/workspace, and default repo settings:
bash
undefined上下文用于存储主机、项目/工作区和默认仓库设置:
bash
undefinedCreate context for Data Center
为Data Center创建上下文
bkt context create dc-prod --host bitbucket.example.com --project ABC --set-active
bkt context create dc-prod --host bitbucket.example.com --project ABC --set-active
Create context for Cloud
为Cloud创建上下文
bkt context create cloud-team --host bitbucket.org --workspace myteam --set-active
bkt context create cloud-team --host bitbucket.org --workspace myteam --set-active
List and switch contexts
列出并切换上下文
bkt context list
bkt context use cloud-team
undefinedbkt context list
bkt context use cloud-team
undefinedQuick Command Reference
快速命令参考
| Task | Command |
|---|---|
| List repos | |
| View repo | |
| Clone repo | |
| Create repo | |
| List PRs | |
| View PR | |
| Create PR | |
| Merge PR | |
| PR checks | |
| List branches | |
| Create branch | |
| Delete branch | |
| List issues (Cloud) | |
| Create issue | |
| Webhooks | |
| Run pipeline | |
| API escape hatch | |
| 任务 | 命令 |
|---|---|
| 列出仓库 | |
| 查看仓库详情 | |
| 克隆仓库 | |
| 创建仓库 | |
| 列出拉取请求 | |
| 查看拉取请求详情 | |
| 创建拉取请求 | |
| 合并拉取请求 | |
| 拉取请求检查 | |
| 列出分支 | |
| 创建分支 | |
| 删除分支 | |
| 列出问题(仅Cloud) | |
| 创建问题 | |
| Webhook管理 | |
| 运行流水线 | |
| 原生API调用 | |
Repository Operations
仓库操作
bash
bkt repo list --limit 20
bkt repo list --workspace myteam # Cloud workspace override
bkt repo view platform-api
bkt repo create data-pipeline --description "Data ingestion" --project DATA
bkt repo browse --project DATA --repo platform-api
bkt repo clone platform-api --sshbash
bkt repo list --limit 20
bkt repo list --workspace myteam # 覆盖Cloud工作区设置
bkt repo view platform-api
bkt repo create data-pipeline --description "数据采集" --project DATA
bkt repo browse --project DATA --repo platform-api
bkt repo clone platform-api --sshPull Request Workflows
拉取请求工作流
bash
undefinedbash
undefinedList and view
列出和查看
bkt pr list --state OPEN --limit 10
bkt pr list --mine # PRs you authored
bkt pr view 42
bkt pr view 42 --web # Open in browser
bkt pr list --state OPEN --limit 10
bkt pr list --mine # 你创建的拉取请求
bkt pr view 42
bkt pr view 42 --web # 在浏览器中打开
Create and edit
创建和编辑
bkt pr create --title "feat: cache" --source feature/cache --target main --reviewer alice
bkt pr edit 123 --title "New title" --body "Updated description"
bkt pr create --title "feat: 缓存功能" --source feature/cache --target main --reviewer alice
bkt pr edit 123 --title "新标题" --body "更新后的描述"
Review and merge
评审和合并
bkt pr approve 42
bkt pr comment 42 --text "LGTM"
bkt pr merge 42 --message "merge: feature/cache"
bkt pr merge 42 --strategy fast-forward
bkt pr approve 42
bkt pr comment 42 --text "LGTM"
bkt pr merge 42 --message "merge: feature/cache"
bkt pr merge 42 --strategy fast-forward
CI/build status
CI/构建状态
bkt pr checks 42 # Show build status
bkt pr checks 42 --wait # Wait for builds to complete
bkt pr checks 42 --wait --timeout 5m # With timeout
bkt pr checks 42 --fail-fast # Exit on first failure
bkt pr checks 42 # 查看构建状态
bkt pr checks 42 --wait # 等待构建完成
bkt pr checks 42 --wait --timeout 5m # 设置超时时间
bkt pr checks 42 --fail-fast # 首次失败即退出
Checkout locally
本地检出
bkt pr checkout 42 # Fetches to pr/42 branch
undefinedbkt pr checkout 42 # 拉取到pr/42分支
undefinedBranch Management
分支管理
bash
bkt branch list
bkt branch list --filter "feature/*"
bkt branch create release/1.9 --from main
bkt branch delete feature/old-stuff
bkt branch set-default main # DC only
bkt branch protect add main --type fast-forward-only # DC onlybash
bkt branch list
bkt branch list --filter "feature/*"
bkt branch create release/1.9 --from main
bkt branch delete feature/old-stuff
bkt branch set-default main # 仅Data Center支持
bkt branch protect add main --type fast-forward-only # 仅Data Center支持Issue Tracking (Bitbucket Cloud Only)
问题追踪(仅Bitbucket Cloud)
bash
bkt issue list --state open --kind bug
bkt issue view 42 --comments
bkt issue create -t "Login broken" -k bug -p major
bkt issue edit 42 --assignee "{uuid}" --priority critical
bkt issue close 42
bkt issue reopen 42
bkt issue comment 42 -b "Fixed in v1.2.0"
bkt issue status # Your assigned/created issuesIssue kinds: , , ,
Priorities: , , , ,
bugenhancementproposaltasktrivialminormajorcriticalblockerbash
bkt issue list --state open --kind bug
bkt issue view 42 --comments
bkt issue create -t "登录功能异常" -k bug -p major
bkt issue edit 42 --assignee "{uuid}" --priority critical
bkt issue close 42
bkt issue reopen 42
bkt issue comment 42 -b "已在v1.2.0版本修复"
bkt issue status # 你分配/创建的问题问题类型:、、、
优先级:、、、、
bugenhancementproposaltasktrivialminormajorcriticalblockerWebhooks
Webhook管理
bash
bkt webhook list
bkt webhook create --name "CI" --url https://ci.example.com/hook --event repo:refs_changed
bkt webhook delete <id>
bkt webhook test <id>bash
bkt webhook list
bkt webhook create --name "CI" --url https://ci.example.com/hook --event repo:refs_changed
bkt webhook delete <id>
bkt webhook test <id>Pipelines (Cloud)
流水线(仅Cloud)
bash
bkt pipeline run --ref main --var ENV=staging
bkt pipeline list # Recent runs
bkt pipeline view <uuid> # Pipeline details
bkt pipeline logs <uuid> # Fetch logs
bkt status pipeline <uuid> # Alt: status checkbash
bkt pipeline run --ref main --var ENV=staging
bkt pipeline list # 最近的运行记录
bkt pipeline view <uuid> # 流水线详情
bkt pipeline logs <uuid> # 获取日志
bkt status pipeline <uuid> # 替代方式:状态检查Permissions (DC)
权限管理(仅Data Center)
bash
bkt perms project list --project DATA
bkt perms project grant --project DATA --user alice --perm PROJECT_WRITE
bkt perms repo list --project DATA --repo platform-api
bkt perms repo grant --project DATA --repo api --user alice --perm REPO_WRITEbash
bkt perms project list --project DATA
bkt perms project grant --project DATA --user alice --perm PROJECT_WRITE
bkt perms repo list --project DATA --repo platform-api
bkt perms repo grant --project DATA --repo api --user alice --perm REPO_WRITERaw API Access
原生API访问
For endpoints not yet wrapped:
bash
bkt api /rest/api/1.0/projects --param limit=100 --json
bkt api /repositories --param workspace=myteam --field pagelen=50对于尚未封装的接口:
bash
bkt api /rest/api/1.0/projects --param limit=100 --json
bkt api /repositories --param workspace=myteam --field pagelen=50Output Modes
输出模式
All commands support structured output:
bash
bkt pr list --json # JSON output
bkt pr list --yaml # YAML output
bkt pr list --json | jq '.pull_requests[0].title'所有命令均支持结构化输出:
bash
bkt pr list --json # JSON格式输出
bkt pr list --yaml # YAML格式输出
bkt pr list --json | jq '.pull_requests[0].title'Global Options
全局选项
- /
--json— Structured output--yaml - — Use specific context
--context <name> - — Override project (DC)
--project <key> - — Override workspace (Cloud)
--workspace <name> - — Override repository
--repo <slug>
- /
--json— 结构化输出--yaml - — 使用指定上下文
--context <name> - — 覆盖项目设置(仅Data Center)
--project <key> - — 覆盖工作区设置(仅Cloud)
--workspace <name> - — 覆盖仓库设置
--repo <slug>
Environment Variables
环境变量
- — Config directory override
BKT_CONFIG_DIR - — Allow file-based credential storage
BKT_ALLOW_INSECURE_STORE - — Keyring operation timeout (for example
BKT_KEYRING_TIMEOUT)2m
- — 覆盖配置目录
BKT_CONFIG_DIR - — 允许基于文件的凭据存储
BKT_ALLOW_INSECURE_STORE - — 密钥环操作超时时间(例如
BKT_KEYRING_TIMEOUT)2m
References
参考资料
- Full command reference: See references/commands.md
- 完整命令参考:查看references/commands.md