用于获取Bitbucket服务器用户拥有的列表或存储库的API?

时间:2018-04-03 16:01:19

标签: bitbucket bitbucket-server bitbucket-api

作为In Bitbucket API, how can I get a list of ALL licensed users?的后续内容,我知道想找到用户拥有的所有回购。但是,BB-server API似乎没有为repos端点提供过滤器?而且,似乎回购没有业主的概念?如果我这样做

$ curl -s -u USER:PW -X GET https://bitbucket-server.domain.com/bitbucket/rest/api/1.0/repos?name=apr-util | jq --raw-output '.values[]'

我得到了

{
  "links": {
    "self": [
      {
        "href": "https://bitbucket-server.domain.com/bitbucket/projects/CAGLXY/repos/apr-util/browse"
      }
    ],
    "clone": [
      {
        "name": "ssh",
        "href": "ssh://git@bitbucket-server.domain.com:7999/caglxy/apr-util.git"
      },
      {
        "name": "http",
        "href": "https://user@bitbucket-server.domain.com/bitbucket/scm/caglxy/apr-util.git"
      }
    ]
  },
  "public": false,
  "slug": "apr-util",
  "id": 6289,
  "name": "apr-util",
  "scmId": "git",
  "state": "AVAILABLE",
  "statusMessage": "Available",
  "forkable": true,
  "project": {
    "links": {
      "self": [
        {
          "href": "https://bitbucket-server.domain.com/bitbucket/projects/CAGLXY"
        }
      ]
    },
    "type": "NORMAL",
    "public": false,
    "description": "Project to house company's Ansible Git repos",
    "name": "ansible-galaxy",
    "id": 1883,
    "key": "CAGLXY"
  }
}

我没有看到“所有者”属性。有没有直接的方法来获取用户拥有的回购列表?如果不是,我将如何编制用户拥有的回购列表?

1 个答案:

答案 0 :(得分:1)

非个人存储库没有所有者,但您可以使用以下命令列出个人存储库:

curl -s --user USER:PASS --request GET https://BITBUCKET-SERVER/rest/api/1.0/projects/~USER/repos | jq --raw-output '.values[].slug'