Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

649 views 2 18
Read article

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