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.
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.