I am trying to restrict users from pushing to a specific Directory via "protect git refs" pre-receive hook, the script below is restricting users from pushing into "season" directory, however, it is also restricting pushes to other files outside season directory.
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.auth.AuthenticationContext
import com.atlassian.bitbucket.user.UserService
def userService = ComponentLocator.getComponent(UserService)
def authContext = ComponentLocator.getComponent(AuthenticationContext)
if (pathsMatchExcludingDeletes('glob:season/**')) {
return ! userService.isUserInGroup(authContext.getCurrentUser(), "authorised-devs")
}
return false
Any help would be appreciated.
Hi Mani! For this kind of questions, you'll be more likely to get the assistance you need in our Developer Community. For the future, you might also be interested to check our Developer resources.
Hope that helps!
Ana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.