Limit pull request approver permission on a directory level

One of our repositories is extremely large with many directories. This is largely due to an organic growth. While it is clear that we should refactor the code base, we are not prepared to at this time.

Often, the senior developers who have expertise and knowledge of one directory are completely ignorant about the contents of another. For example, we might have one directory that manages UI and another one that manages handling requests.

The problem arises with requiring approval for pull requests. It appears that the ability to approve a pull request is only available on a per-repository + per-branch basis. How do I get more granular than that? How do I allow a directory within a specific repository and branch have a different set of approvers than another directory within that same repository and branch?

3 answers

1 accepted

4 votes
Answer accepted


Adaptavist have recently released a new Add-on to the Marketplace that should solve your particular use case called ScriptRunner for Stash. This Add-on does many things but the area your most interested in is the feature of enforcing mandatory approvers (users or groups) automatically.

This screenshot should show how you could configure the Auto Add Approver Event Handler to suit your needs for a repository called "big-repo" and a directory with the path matching the condition (note: there are other conditions or you can write your own groovy scripted condition):


On this occasion I've configured the user "Frank N Stein" and all members of the group "front-end-engineers" to be mandatory reviewers of all Pull Requests that match the repository and the conditional path (or directory).

There is also a video you can watch on our Adaptavist ScriptRunner Youtube Channel which runs you through the Auto Add Reviewer functionality.

I hope that helps but feel free to let us know if it doesn't. We'd be glad to try and help. The best way to raise a question is on our Product Support Service Desk Portal.

Hi Nik,

While you can't do this "out of the box", you could create a custom "merge check" plugin that would allow you to require certain developers approvals on PRs where certain paths have been modified. 

There's an excellent tutorial on merge checks in the Stash developer documentation here:

Hope this helps!



Tim - how do we log this as a feature we'd like to have incorporated in the core product?

You can enter a request at Post a link here if you do so that people who see this and agree can vote for it.

I don't think you can do this with Stash.  Certainly not out of the box.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables ROLLBAR_ACCESS_TOKEN...

186 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you