Samples or commands for modifying bitbucket branch permissions using powershell or git commands.
We do not have Bit bucket CLI rather, hence suggest a good approach model to execute the above scenario.
I've done it with bash and the free token authenticator add-on. Here's a sample script for setting the "no changes" permission (with Group1 and Group2 exempt from it) against the current "development" branch (based on the branching model):
#!/bin/bash
export TOKEN='Fr1bRsIEPq[...]AmM='
read -r -d '' JSON <<'EOF'
{"type":"read-only", "matcher":{"id":"development", "type":{"id":"MODEL_BRANCH"}, "active":true}, "users":[], "groups":["Group1","Group2"]}
EOF
echo $JSON |
curl -s -H "X-Auth-User:gsylvie" \
-H "X-Auth-Token:$TOKEN" \
-H "Content-Type: application/json" \
--data @- -X POST \
https://vm.bit-booster.com/bitbucket/rest/branch-permissions/2.0/projects/PROJECT/repos/repo/restrictions
Deleting branch permissions is a bit trickier. I had to resort to installing the jq command from github to extract the ID of the restriction to delete:
export ID=$(\
echo $JSON | \
jq '.values[] | select(.type=="read-only" and .matcher.id=="development") | .id' \
)
If you're trying to propagate a standard set of branch permissions out to all your repositories then I recommend using my paid add-on: Control Freak for Bitbucket Server.
Hi Daniel! Git itself does not have branch permissions. You could create one private repository and one public repository and only push the development branch to the public on while keeping the master only in your private repository.
For branch specific permissions you need a server-side authorization layer like Gitolite for example (note that this requires you to be managing your own Git server). You can find more info at Git on the Server Gitolite.
Alternatively, you can use Bitbucket to manage branch permissions. You can learn more in the article Using branch permissions.
Hope that helps!
Ana
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.