Push restriction

Mani Reddy June 14, 2018

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.

1 answer

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 22, 2018

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events