Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove right to a groups in all projects

Alexandre Boueye May 16, 2024

Hello, 

We want to remove a group from all the project, we have added the wrong level of permission and whe want to change that. 

We have script runner and we use Jira DC 9.4.12

Thank you for your help

Regards

 

Here's the script we used fot adding. 

//// Script to add group to project role in ALL Jira projects
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleActor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.util.SimpleErrorCollection



def groupManager = ComponentAccessor.getGroupManager()
def projectManager = ComponentAccessor.getProjectManager()
def projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def errorCollection = new SimpleErrorCollection()

// Fetch project role object by name
def projectRole = projectRoleManager.getProjectRole("role")

// Fetch group (case insensitive) and add to list (addActorsToProjectRole requires a list)
def group = groupManager.getGroup("group name").name
def list = new ArrayList<String>()
list.add(group)

// Fetch ALL Jira projects and loop add group to project role on each project
def projects = projectManager.getProjects()
for(item in projects) {
projectRoleService.addActorsToProjectRole(list,projectRole,item,ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE,errorCollection)
}
// Print errors in log
log.warn(errorCollection)

1 answer

1 accepted

1 vote
Answer accepted
Laurie Sciutti
Community Champion
May 16, 2024

hello @Alexandre Boueye ~ can't you use the same script but use the projectRoleService.removeActorsToProjectRole method instead of the projectRoleService.addActorsToProjectRole method?

Alexandre Boueye May 17, 2024

Hello @Laurie Sciutti

Thank you !

It leads to a change 

projectRoleService.removeActorsFromProjectRole(list,projectRole,item,ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE,errorCollection)
Like Laurie Sciutti likes this
Laurie Sciutti
Community Champion
May 17, 2024

Oops!  yes ~ remove FROM!

Like Alexandre Boueye likes this

Suggest an answer

Log in or Sign up to answer