You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Dear Bitbucket Community,
I have a question regarding branch restrictions - I created new branch restriction via the API. The group which I white listed for push has also rights to delete or rewrite the branch. If the restriction is created via the interface, those settings are not marked by default and I would want to disable them via the API. I looked for flags, related with the custom settings, where they appear when are in use, but I did not find anything. This is the payload which I use with POST request to create the branch restriction:
{
"type": "branch",
"branch_match_kind": "glob",
"users": [],
"groups": [
{
"slug": "my-team",
"type": "group"
}
],
"kind": "push",
"pattern": "elena-branch",
}
)
Even with default_permission and account_privilege flag, the permissions for delete and rewrite branch histrory are still active:
{
"branch_match_kind": "glob",
"groups": [{
"default_permission": "read",
"account_privilege": "read",
"name": "my-team",
"slug": "my-team",
"type": "group"
}],
"kind": "push",
"pattern": "elena-branch"
}
Thank you for reaching out to the community.
I understand that you'd like to uncheck the two branch restriction settings below via API:
If that's correct, you can uncheck those settings by running two POST commands specifically changing the parameter "kind":
To uncheck "Allow rewriting branch history", you can use the CURL command below:
curl -u bb_username:app_password -X POST -k -H 'Content-Type: application/json; charset=utf-8' --data '{"kind": "force", "branch_match_kind": "glob", "pattern": "elena-branch"}' https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/branch-restrictions
To uncheck "Allow deleting this branch", you can use the CURL command below:
curl -u bb_username:app_password -X POST -k -H 'Content-Type: application/json; charset=utf-8' --data '{"kind": "delete", "branch_match_kind": "glob", "pattern": "elena-branch"}' https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/branch-restrictions
I hope it helps and let me know how it goes.
Regards,
Mark C
Hello @Mark C !
Thank you a lot for the help!
Both POST commands worked as expected and the functionalities are disabled for the desired branch!
Best Regards,
Elena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.