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

Nik,

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):

Event_Handlers_-_Stash.png

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: https://developer.atlassian.com/stash/docs/latest/tutorials-and-examples/controlling-when-pull-requests-can-be-merged.html

Hope this helps!

cheers,

Tim

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 jira.atlassian.com. 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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

716 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot