Skip to main content
Book your demo
Example scripts
To homepage
Bitbucket
Data centre icon
Data Center

Prevent Project Administrators from changing the Project Key

Features
Listeners
Created 2 year(s) ago, Updated 13 day(s) ago
App in script
ScriptRunner For Bitbucket
ScriptRunner For Bitbucket
by Adaptavist
Compatibility
compatibility bullet
Bitbucket (6.0 - 7.17)
compatibility bullet
ScriptRunner For Bitbucket (7.10.0)
Language |
groovy
import com.atlassian.bitbucket.event.project.ProjectModificationRequestedEvent
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.sal.api.user.UserManager
import com.atlassian.sal.api.user.UserKey

def userManager = ComponentLocator.getComponent(UserManager)
def currentEvent = event as ProjectModificationRequestedEvent

if (!userManager.isAdmin(new UserKey(currentEvent.user.name)) && currentEvent.isKeyChanged()) {
    currentEvent.cancel("You do not have the correct permissions to change the Project Key.")
}
Having an issue with this script?
Report it here