Bitbucket API 添加分支限制 - 格式错误的组

Bitbucket API adding branch restriction - malformed groups

尝试将分支限制添加到存储库,我成功添加了规则,但是,我无法将组添加到规则中。

curl -XPOST --user user:password -H "Content-Type: application/json" -d '{"kind": "push", "pattern": "testing*", "groups": {"name": "testleads"}}' $URL/api/2.0/repositories/team/repo/branch-restrictions

结果:

{"error": {"message": "malformed groups"}}

我在组中尝试了不同的组合,使用 full_slug、slug 并更改了继承类型。

-d '{"kind": "push", "pattern": "testing*", "groups":["name": "devleads"]}'
-d '{"kind": "push", "pattern": "testing*", "groups": {"name": "devleads"}}'

有人试过吗?

经过多次尝试,我将范围缩小到这个 JSON 输入以便能够添加分支限制

-d '{"kind": "push", "pattern": "test*", "value": null, "groups": [{"name": "devLeads", "account_privilege": null, "full_slug": "team-name:devleads", "owner": {"username": "team-name", "display_name": "Team Name ", "type": "team"}, "type": "group", "slug": "devleads"}]}'

我来晚了,但我想我的回答可能对任何像我刚才一样为此苦苦挣扎的人都有用。我发现组规范的最小语法如下:

'groups': [{'name': 'development_team'}]

因此,在我的上下文中(使用 python),以下内容可以成功发布到 BitBucket API:

request_json = {
        "kind": "push",
        "branch_match_kind": "glob",
        "pattern": "*_bugfix",
        'groups': [{'name': 'development_team'}]
    }

lock_response = requests.post(api_url, json=request_json, auth=bb_creds)