跳转到内容

cnb-rs badge upload

cnb-rs badge upload --key <key> --sha <sha> --message <msg> [options]

上传自定义徽章数据。

自定义徽章用于在 CI/CD 流水线中上报代码质量、安全扫描等自定义指标。 上传后可通过 cnb-rs badge get 获取对应的 SVG 或 JSON 数据。

key 限制

CNB 后端目前只允许 key=security/tca,传其他值返 HTTP 400 [PARAM_INVALID]key is invalid. Only the following keys are allowed: security/tca

选项

  • -k, --key <KEY>: Badge key,当前 CNB 只接受 security/tca(必填)
  • --sha <SHA>: Commit SHA(必填)
  • -m, --message <MSG>: Badge 右侧显示内容(必填)
  • --value <NUM>: Badge 数值
  • -l, --link <URL>: 点击 badge 跳转链接
  • --latest: 同时上传 latest 标记 badge

继承的全局选项:

  • --repo <REPO>: 指定仓库路径(格式:group/repo
  • --domain <DOMAIN>: 指定目标域名(默认:cnb.cool

示例

bash
$ cnb-rs badge upload --key security/tca --sha abc12345 \
    --message "A+" --value 95 \
    --link "https://example.com/report" \
    --latest
 徽章已上传
  Commit URL: https://cnb.cool/.../badge/git/abc12345/security/tca
  Latest URL: https://cnb.cool/.../badge/git/latest/security/tca

另请参阅

Released under the MIT License.