ABC can only be changed by certain users: if any other user tries to push changes to that directory, they should be blocked from doing so.
I tried below script using “Protect git ref” in script runner and it doesn’t work.
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 any of the paths start with “ABC”, check if user has perms to push
if (pathsMatch(“glob:ABC/*”)){
// return true if the user is NOT in the desired group, thus blocking the push
return ! userService.isUserInGroup(authContext.getCurrentUser(), "stash-users")
// I am in Stash-users group, I should be able to push however I am unable to push into ABC and also to the files outside ABC.
}
//if paths does not start with “ABC”, let users push
return false
Any help would be appreciated.