Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trying to create a branch permission, What should be structure of my JSON payload

sidhant June 4, 2023

I'm using this API endpoint as mentioned in the documentation:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-branch-restrictions/#api-repositories-workspace-repo-slug-branch-restrictions-post

These are the permission i want to give:

Screenshot 2023-06-04 at 6.23.51 PM.pngScreenshot 2023-06-04 at 6.24.05 PM.png

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 6, 2023

Hi @sidhant,

I am posting below the data that is required for each branch restriction. Please keep in mind that each one of them needs to be created with a separate API call:

{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "push",
"users": [{"uuid": "{bt6e7413-je0e-4k93-68a2-00g19416f787}"}]
}'

where bt6e7413-je0e-4k93-68a2-00g19416f787 replace with the UUID of the user you want to add


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "force",
"value": null
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "delete",
"value": null
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_approvals_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_default_reviewer_approvals_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_no_changes_requested"
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_passing_builds_to_merge",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "require_commits_behind",
"value": 1
}


{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "reset_pullrequest_changes_requested_on_change"
}

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

Elena Dzhordzhilova October 3, 2023

Hello, 

I have a question regarding "kind": "push". I would want to know if there is a way to update the branch restriction with list of users. I am using uuid of the users with the following paylaod and PUT request: 

{
"branch_match_kind": "glob",
"users": [{
"uuid": user_uuid (here I use variable and I want to add multiple users)
}],
"kind": "push",
"pattern": branch-name

 The result is that when I execute the request, only one user is being added (the last one) and all other users are being removed from the list - does not matter if they are added by hand via the interface or with script.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 4, 2023

Hi Elena,

You can add multiple users with the following data:

{
"branch_match_kind": "glob",
"pattern": "*_*_*_feature",
"kind": "push",
"users": [{"uuid": "{bt6e7413-je0e-4k93-68a2-00g19416f787}"}, {"uuid": "{ae5u9460-be7r-2k65-68v4-74a62825h487}"}]
}

Please keep in mind that if there is an existing branch restriction for the branch and userA has permission to push, if you run an API call to add userB and userC then userA is going to be removed. You will need to run an API call that includes all three users if you don't want userA to be removed.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events