Bitbucket Cloud - Automatically add default approvers when creating a new pull request via the API

Paolo.Ascari May 16, 2023

Hello, using the Bitbucket CLOUD API:

  • Is there a way to have default approvers automatically added when creating a new pull request?

and/or:

  • Is there an endpoint to get a list of a repository's default approvers?

Thanks in advance for any pointers!

1 answer

1 accepted

1 vote
Answer accepted
Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 16, 2023

Welcome to the community @Paolo.Ascari !

I suppose you could fetch the repository or project default reviewer configuration via the Bitbucket REST API [1] and update the pull request with these reviewers [2].

Another option is to use a convenient app like Workzone for Bitbucket cloud [3] where you can configure reviewers or reviewer groups at branch- or even file/path-level and the app will add them automatically when a PR is created. You can also enforce how many approvals you require before the PR can be merged.

Hope that helps, and please let me know if you need any further assistance.

Best, Ulrich

 

[1] https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-effective-default-reviewers-get

[2] https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-put

[3] https://marketplace.atlassian.com/apps/1211303/workzone-pullrequest-workflow?hosting=cloud&tab=overview

Disclosure: Izymes offers Workzone for Bitbucket Cloud and Server on the Atlassian Marketplace.

Paolo.Ascari May 17, 2023

Hello Ulrich, and thank you for the detailed reply.

The default reviewers endpoint [1] has proven very useful, so we are going with that.

It's unfortunate that, when creating pull requests, the API doesn't mimic the front-end (i.e. automatically adding default reviewers), which means we always have to call an additional endpoint first.

Personally, I believe that the API endpoint should always add the default reviewers if this field is missing from the payload, as the caller would still have the option to pass an empty array to intentionally obtain the current behaviour.

Cheers, Paolo

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events