turbot/bitbucket
steampipe plugin install bitbucket

Table: bitbucket_pull_request - Query Bitbucket Pull Requests using SQL

Bitbucket Pull Requests is a feature within Bitbucket that allows developers to review code and discuss changes before merging into the main code base. It helps in maintaining code quality, fostering collaboration, and promoting a more transparent development process. With pull requests, teams can ensure that only thoroughly reviewed and approved code gets merged, reducing the risk of introducing bugs.

Table Usage Guide

The bitbucket_pull_request table provides insights into pull requests within Bitbucket. As a developer or team lead, you can explore pull request details through this table, including the author, reviewers, status, and associated metadata. Utilize it to monitor the progress of code reviews, track the status of pull requests, and ensure efficient collaboration within your team.

Important Notes

  • You must specify the repository_full_name in the where clause to query this table.

Examples

List open pull requests in a repository

Explore which pull requests are currently open in a specific repository. This is useful to track ongoing changes and contributions to a project.

select
repository_full_name,
id,
title,
state,
branch_name,
author_display_name
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and state = 'OPEN';
select
repository_full_name,
id,
title,
state,
branch_name,
author_display_name
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and state = 'OPEN';

List the pull requests for a repository that have been merged in the last week

This query is useful for tracking recent changes in a specific repository, specifically identifying which pull requests have been merged in the past week. It provides valuable insights into the recent activity and contributor involvement, aiding in project management and review processes.

select
repository_full_name,
id,
title,
state,
updated as merged_at,
closed_by_display_name as merged_by_name,
closed_by_uuid as merged_by_uuid
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and state = 'MERGED'
and updated >= (current_date - interval '7' day)
order by
updated desc;
select
repository_full_name,
id,
title,
state,
updated as merged_at,
closed_by_display_name as merged_by_name,
closed_by_uuid as merged_by_uuid
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and state = 'MERGED'
and updated >= date('now', '-7 day')
order by
updated desc;

List the open PRs in a repository assigned to a specific user

Determine the open project requests assigned to a specific user within a particular repository. This is useful in tracking the workload and contributions of individual team members.

select
repository_full_name,
id,
title,
state,
author_display_name,
author_uuid
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and author_display_name = 'Tom Gibson'
and state = 'OPEN';
select
repository_full_name,
id,
title,
state,
author_display_name,
author_uuid
from
bitbucket_pull_request
where
repository_full_name = 'bitbucketpipelines/official-pipes'
and author_display_name = 'Tom Gibson'
and state = 'OPEN';

Schema for bitbucket_pull_request

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
author_display_nametextDisplay name of the author of this pull request.
author_uuidtextUUID of the author of this pull request.
branch_nametextName of the source branch for the pull request.
close_source_branchbooleanA boolean flag indicating if merging the pull request closes the source branch.
closed_by_display_nametextDisplay name of the user who closed this pull request.
closed_by_uuidtextUUID of the user who closed of this pull request.
comment_countbigintThe number of comments for a specific pull request.
createdtimestamp with time zoneTimestamp when pull request was created.
descriptiontextDescription of the pull request.
editedtimestamp with time zoneTimestamp when pull request was last edited.
idbigint=The pull request's unique ID. Note that pull request IDs are only unique within their associated repository.
merge_committextMerge commit hash details for pull request.
participantsjsonbList of collaborators on the pull request.
repository_full_nametext=The repository's full name.
reviewersjsonbList of reviewers of the pull request.
self_linktextA self link to this pull request.
statetextA current state of the pull request. Can be one of "MERGED", "SUPERSEDED", "OPEN" and "DECLINED".
summarytextSummary details of the pull request.
task_countbigintThe number of open tasks for a specific pull request.
titletextTitle of the resource.
typetextType of the Bitbucket resource. It will be always "pullrequest".
updatedtimestamp with time zoneTimestamp when pull request was last updated.

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_pull_request