Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,297,271
Community Members
 
Community Events
165
Community Groups

Bulk Assign Permission Scheme

Hello,

I am trying to create a simple script to bulk assign permission scheme on a list of project using scriptrunner.

My script looks like that: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.permission.PermissionSchemeService
import com.atlassian.jira.permission.PermissionScheme
import org.apache.log4j.Logger

def log = Logger.getLogger("ch.vaudoise.project.bulkedit.permissionScheme")

// Get the Project Manager
def projectManager = ComponentAccessor.getProjectManager()
def pss = ComponentAccessor.getComponent(PermissionSchemeService)
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

//######################################################################################
// VARIABLES
def permissionScheemeID = 11201
// This will be the list of all the projects, testing script for 1 project now
def projs_key = ['RCVI','AIARUN','CBCV','DOMVIE','SDPV','EMDPAP','AIAMAIN','PYTHONSDP','PPRE','PU','AIADC','AIAINVAL','AIARENTVIA','RFISC','AIARYTDZ','VAVALOR','RIA','AIATREND']
//######################################################################################

// Iterate over each Project Object
def project = projectManager.getProjectObjects()

project.each {

try {
if (projs_key.contains(it.key))
{
PermissionScheme permscheme = pss.getSchemeAssignedToProject(currentUser,it.id).get()
def permschemeName = permscheme.getName()
log.info "project = ${it.key} , previous Scheme = ${permschemeName}"
pss.assignPermissionSchemeToProject(currentUser, permissionScheemeID, it.id)

}
}
catch(e)
{
log.error "Ran into a problem for ${it.key} n\" + e.message"
}
}

 

But it trigger a NullPointerException when executing.

Do you already faced any issue with assignPermissionSchemeToProject or do you have any idea what is wrong with this script ?

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

352 views 0 10
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you