Rate this page:
Repository owners and administrators can set branch management rules on a repository that control what can be pushed by whom. Through these rules, you can enforce a project or team workflow. For example, owners or administrators can:
GET /2.0/repositories/{workspace}/{repo_slug}/branch-restrictions
Returns a paginated list of all branch restrictions on the repository.
repository:admin
string
This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}
.
string
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}
.
string
Branch restrictions of this type
string
Branch restrictions applied to branches of this pattern
1 2 3 4
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/branch-restrictions' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json'
A paginated list of branch restrictions
Content type | Value |
---|---|
application/json |
POST /2.0/repositories/{workspace}/{repo_slug}/branch-restrictions
Creates a new branch restriction rule for a repository.
kind
describes what will be restricted. Allowed values include:
push
, force
, delete
and restrict_merges
.
Different kinds of branch restrictions have different requirements:
push
and restrict_merges
require users
and groups
to be
specified. Empty lists are allowed, in which case permission is
denied for everybody.The restriction applies to all branches that match. There are
two ways to match a branch. It is configured in branch_match_kind
:
glob
: Matches a branch against the pattern
. A '*'
in
pattern
will expand to match zero or more characters, and every
other character matches itself. For example, 'foo*'
will match
'foo'
and 'foobar'
, but not 'barfoo'
. '*'
will match all
branches.branching_model
: Matches a branch against the repository's
branching model. The branch_type
controls the type of branch
to match. Allowed values include: production
, development
,
bugfix
, release
, feature
and hotfix
.The combination of kind
and match must be unique. This means that
two glob
restrictions in a repository cannot have the same kind
and
pattern
. Additionally, two branching_model
restrictions in a
repository cannot have the same kind
and branch_type
.
users
and groups
are lists of users and groups that are except from
the restriction. They can only be configured in push
and
restrict_merges
restrictions. The push
restriction stops a user
pushing to matching branches unless that user is in users
or is a
member of a group in groups
. The