You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过Bitbucket Cloud API为仓库添加Access Key?

可以通过Bitbucket Cloud API添加仓库级Access Key(部署密钥)

当然可以,Bitbucket Cloud API提供了专门的接口来管理仓库的部署密钥:

  • 核心操作是向特定仓库的部署密钥端点发送POST请求,接口路径格式为/2.0/repositories/{工作区ID}/{仓库slug}/deploy-keys
  • 请求体需要包含两个必填字段:
    • label:给这个密钥起的标识名称,方便区分
    • key:完整的SSH公钥内容(比如ssh-rsa AAAAB3NzaC1yc2E...开头的字符串)
  • 默认情况下添加的部署密钥就是只读权限,如果需要读写权限,可在请求体里额外加上permission: write参数

举个简单的请求示例(用curl的话):

curl -X POST -u 你的用户名:API令牌 \
  https://api.bitbucket.org/2.0/repositories/你的工作区/目标仓库/deploy-keys \
  -H "Content-Type: application/json" \
  -d '{
    "label": "CI服务器部署密钥",
    "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...",
    "permission": "read"
  }'

另外,你也可以用这个API做其他操作,比如列出仓库所有部署密钥、删除指定密钥,完全覆盖网页端的功能。

内容的提问来源于stack exchange,提问作者Paolo Brandoli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 06:01:07