This article explains how to add branch level restriction using Bitbucket Command Line Interface (CLI) app.
Instructions
Use the runFromBranchList CLI action to get the list of branches for a repository and addBranchRestriction to add branch level restriction.
- Ensure that the CLI client file is updated with the required information.
Execute the below CLI action:
--action runFromBranchList --project "project1" --repository "repository1" --common "-a addBranchRestriction --project "project1" --repository "repository1" --branch @branch@ --group "group1""
Output:
Run: -a addBranchRestriction --project project1 --repository repository1 --branch admin/COTtxt-1585834077505 --group group1 Branch restriction 'read-only' added with id 1. Run: -a addBranchRestriction --project project1 --repository repository1 --branch master --group group1 Branch restriction 'read-only' added with id 2. Run: -a addBranchRestriction --project project1 --repository repository1 --branch ABCD5-1-testing-4132 --group group1 Branch restriction 'read-only' added with id 3. Run: -a addBranchRestriction --project project1 --repository repository1 --branch develop --group group1 Branch restriction 'read-only' added with id 4. Run: -a addBranchRestriction --project project1 --repository repository1 --branch develop1 --group group1 Branch restriction 'read-only' added with id 5. Run: -a addBranchRestriction --project project1 --repository repository1 --branch developer --group group1 Branch restriction 'read-only' added with id 6. Run: -a addBranchRestriction --project project1 --repository repository1 --branch admin/COTtxt-1585649449127 --group group1 Branch restriction 'read-only' added with id 7. Run: -a addBranchRestriction --project project1 --repository repository1 --branch admin/COTtxt-1585647043498 --group group1 Branch restriction 'read-only' added with id 8. Run: -a addBranchRestriction --project project1 --repository repository1 --branch admin/COTtxt-1585646764820 --group group1 Branch restriction 'read-only' added with id 9. Run: -a addBranchRestriction --project project1 --repository repository1 --branch testbranch --group group1 Branch restriction 'read-only' added with id 10. Run: -a addBranchRestriction --project project1 --repository repository1 --branch branch1 --group group1 Branch restriction 'read-only' added with id 11. Run completed successfully. 11 actions were successful
Verify in the Branch permissions page to see the added restrictions.