How to get the status of a pull request using Bitbucket Command Line Interface (CLI)
This article explains how to get the status of a pull request using the Bitbucket Command Line Interface (CLI) app. Pull requests are a feature that make it easier for developers to collaborate using Bitbucket.
Instructions
Use getPullRequest action to get the status of a pull request.
Execute the following command to get the status of the pull request:
--action getPullRequest --project "TEST" --repository "repo" --pullRequest "example"
Note that sample parameter values are specified in the given command. You must specify relevant values in this command to get the status of the required pull request in your instance.
The output of CLI action with the sample values displays a 'NEEDS_WORK' status as shown:
Data for pull request: example Project . . . . . . . . . . . : TEST Repository . . . . . . . . . : repo Id . . . . . . . . . . . . . : 18 Version . . . . . . . . . . . : 2 Name . . . . . . . . . . . . : example Description . . . . . . . . . : State . . . . . . . . . . . . : OPEN Created . . . . . . . . . . . : 13/4/20 3:22 PM Updated . . . . . . . . . . . : 13/4/20 4:07 PM From . . . . . . . . . . . . : Id . . . . . . . . . . . . : refs/heads/testam Name . . . . . . . . . . . : testam Latest commit . . . . . . . : 0aaceb5cbfe69e03d00539ce286e50a7423982c0 To . . . . . . . . . . . . . : Id . . . . . . . . . . . . : refs/heads/master Name . . . . . . . . . . . : master Latest commit . . . . . . . : 4e2b94a0d019e21abd21635de7d6d0c1e010a077 Author . . . . . . . . . . . : User . . . . . . . . . . . : User id . . . . . . . . . : automation Display name . . . . . . : Automation Role . . . . . . . . . . . : AUTHOR Reviewers . . . . . . . . . . : Reviewer . . . . . . . . . : User . . . . . . . . . . : User id . . . . . . . . : testam Display name . . . . . : testam Role . . . . . . . . . . : REVIEWER Status . . . . . . . . . : NEEDS_WORK Approved . . . . . . . . : No URL . . . . . . . . . . . . . : http://example.com/projects/TEST/repos/repo/pull-requests/18
The parameters used with the action are:
- --project value refers to the project key.
- --repository value refers to the repository name.
- --pullRequest value refers to the name of the pull request.
It is recommended to test the command in a non-production environment before running in production, or, run the action with --simulate parameter to verify the behaviour before deploying.