Table: bitbucket_branch_restriction - Query Bitbucket Branch Restrictions using SQL
Bitbucket Branch Restrictions is a feature within Bitbucket that allows you to control what actions users can perform on a repository's branches. This includes restricting who can push to a branch, who can merge or delete a branch, and enforcing a minimum number of reviewers for pull requests. It provides a layer of security and control over your codebase, ensuring only authorized users can make significant changes.
Table Usage Guide
The bitbucket_branch_restriction
table provides insights into the restrictions applied to a repository's branches within Bitbucket. As a DevOps engineer or repository administrator, explore branch-specific details through this table, including who can perform certain operations and the restrictions in place. Utilize it to uncover information about branch restrictions, such as those with specific user access, the operations permitted on a branch, and the enforcement of review policies.
Important Notes
- You must specify the
repository_full_name
in thewhere
clause to query this table.
Examples
List the branch restrictions in a repository
Explore the restrictions placed on different branches within a specific repository. This is useful for understanding the limitations and rules that have been set, which can help in managing code changes and merges effectively.
select repository_full_name, id, self_link, kind, value, typefrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep';
select repository_full_name, id, self_link, kind, value, typefrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep';
List the branch restrictions having pattern for branch names
Discover the segments that have specific naming patterns for branch restrictions within a given repository. This is useful to maintain naming conventions and manage access control in a systematic manner.
select repository_full_name, id, self_link, patternfrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep' and pattern = 'test-*';
The provided PostgreSQL query does not contain any PostgreSQL - specific functionsor data types that need to be replaced for SQLite.Therefore,the SQLite query is the same as the PostgreSQL query.Here it is: ` ` ` sqlselect repository_full_name, id, self_link, patternfrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep' and pattern = 'test-*';
### List the branch restrictions associated with a specific userDetermine the specific branch restrictions linked to a particular user within a Bitbucket repository. This allows you to understand and manage access and modification rights for individual users, enhancing repository security and collaboration efficiency.
```sql+postgresselect repository_full_name, bitbucket_branch_restriction.id, self_link, pattern, u ->> 'display_name' as user_namefrom bitbucket_branch_restriction, jsonb_array_elements(users) as uwhere repository_full_name = 'sayan97tb/stmp-rep' and u ->> 'display_name' = 'sayan';
select repository_full_name, bitbucket_branch_restriction.id, self_link, pattern, json_extract(u.value, '$.display_name') as user_namefrom bitbucket_branch_restriction, json_each(users) as uwhere repository_full_name = 'sayan97tb/stmp-rep' and json_extract(u.value, '$.display_name') = 'sayan';
List the branch restrictions having 'branching_model' branch_match_kind
Explore the restrictions on specific branches within a repository to understand its access and modification permissions. This is useful for managing and securing your codebase by controlling who can make changes to specific branches.
select repository_full_name, id, self_link, pattern, branch_match_kindfrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep' and branch_match_kind = 'branching_model';
select repository_full_name, id, self_link, pattern, branch_match_kindfrom bitbucket_branch_restrictionwhere repository_full_name = 'sayan97tb/stmp-rep' and branch_match_kind = 'branching_model';
Schema for bitbucket_branch_restriction
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form, e.g. connection_name. | |
branch_match_kind | text | The Branch match kind for the branch restriction. | |
branch_type | text | The type of branch selected while creating the branch restriction. | |
groups | jsonb | Details of the groups associated with the branch restriction. | |
id | bigint | The unique ID if the branch restriction. | |
kind | text | The type of restriction achieved using the branch restriction. | |
pattern | text | The branch name pattern specified while creating the branch restriction. | |
repository_full_name | text | = | The repository's full name. |
self_link | text | The URL to the branch restriction. | |
title | text | Title of the resource. | |
type | text | The type of the branch operation. | |
users | jsonb | Details of the users associated with the branch restriction. | |
value | bigint | The value associated to the kind for the branch restriction. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- bitbucket
You can pass the configuration to the command with the --config
argument:
steampipe_export_bitbucket --config '<your_config>' bitbucket_branch_restriction