Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how to use the BitbucketCLI action runFromBranchList 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.

  1. Ensure that the CLI client file is updated with the required information. 
  2. Execute the below CLI action action: 

    Code Block
    themeMidnight
    --action runFromBranchList --project "project1" --repository "repository1" --common "-a addBranchRestriction --project "project1" --repository "repository1" --branch @branch@ --group "group1""

    Output:

    Code Block
    themeMidnight
    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 
    
    


  3. Verify in the Branch permissions page to see the added restrictions.

...