I want to allow a merge of a pullrequest only under a certain condition.
I have written a script runner script for that:
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.user.UserService
def userService = ComponentLocator.getComponent(UserService)
if (mergeRequest.pullRequest.pathsMatch("glob:**/spec/**") )
{
mergeRequest.pullRequest.reviewers.findAll { it.approved }.any {
userService.isUserInGroup(it.user, "electronics-lead")
}
}
else
{
return true;
}1)
This script should do a special condition only when files in a folder with name "spec" were touched, modified or deleted.
Remark the else case with the `return true`. When the folder was touched some the additional condition jumps in, otherwise other scripts will run..
Is my approach above correct?
2)
Where do I add this script?
I see following options:
a) "Script Merge Check" under "Require a number of approvers"
b) "Script Event Handlers" under "Auto merge of pull request"; here we have already a script.