I'm attempting to script branch permissions for repos in Bitbucket Cloud, as there's no way to apply permissions per Project/Team. I'm having trouble with the JSON payload. There is an example request here, but the example request is confusing and frustratingly can't be copied/pasted, even. I am making the call with Powershell, and intended to have the JSON payload defined in it's own JSON file that I'll pass into the call.
For example, I'm not sure what href or name to input here-
links: {
self: {
href: string (uri)
name: string
}
}
I've tried a bunch of different ways, but always receive a 400 error with no actual message indicating what isn't correct. The call itself is making it (I can GET branch permissions that I've set up in the UI), so I'm assuming my JSON just isn't formatted correctly or is missing something. Does anyone have any examples of JSON they are using to successfully set branch permissions?
The API docs are indeed confusing, I'm not sure why links element is even mentioned in the request. Here're are some examples of valid payload for create branch restriction endpoint:
{
"branch_match_kind": "glob",
"kind": "restrict_merges",
"pattern": "master",
"users": [
"dpenkin"
]
}
{
"branch_match_kind": "branching_model",
"kind": "push",
"branch_type": "production",
"users": [
"dpenkin"
]
}
{
"pattern": "bar",
"kind": "push"
}
{
"pattern": "foo",
"kind": "require_approvals_to_merge",
"value": 3
}
Hope this helps.
Cheers,
Daniil
Hi,
I had the same struggle with understanding what the group attribute should look like.
Posting the solution now, since it might help others:
{
"branch_match_kind": "branching_model",
"branch_type": "development",
"kind": "restrict_merges",
"groups": [
{
"slug": "my-group-slug",
"owner": {"username": "group-owner-acoount-slug"}
}
]
}
Is it possible to include such examples in the official docs too?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide a complete branch permission configuration in json payload like Merge Checks , Merge Condition selection and selecting multiple users along with a APIs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide a complete branch permission configuration in json payload like Merge Checks , Merge Condition selection and selecting multiple users along with a APIs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.