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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.