You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

2

Prevent Project Administrators from changing the Project Key

Overview

This event listener script prevents project administrators from changing project keys, while still retaining their other privileges.

Good to Know

  • Use this as a Custom Listener for the 'ProjectModificationRequestedEvent' event
  • You can modify this script to prevent changing name or description, using event.isNameChanged() and event.isDescriptionChanged()
  • You can also compare the event.newValue and event.oldValue objects to identify changes in other project properties.

Requirements

  • Bitbucket Bitbucket (6.0 - 7.17)
  • ScriptRunner for Bitbucket ScriptRunner for Bitbucket (6.18.0)
    
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.") }
Discovered an issue? Report it here

Suggested for you