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

How to add group to all projects


Hi! Can anybody help me pls? How can i add a group to the role in all projects via REST API? Since there are a lot of projects and it is very difficult to do this by hands.

I have a jira version 6.3.8



3 answers

1 accepted

0 votes
Answer accepted

Ok, i found one way.
Take the ID of all projects and rewrite them in a text file
Next, create a script with the following code:

for (( i = 1; i < 8; i++ ))
key=$(sed -n $i"p" $1)
echo $key
curl -x http://YourProxyServer:3128/ -i -H 'Content-Type: application/json' -X POST -d '{"group": ["YourGroup"]}' -u user:password https://jira_url/rest/api/latest/project/${key}/role/{roleid}

Hi @kyco4ektopta

If you don't want to do this via REST API there's a way to do it using the ScriptRunner "Script Console";

//// 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.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("Administrators")

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

// Fetch ALL Jira projects and loop add group to project role on each project
def projects = projectManager.getProjects()
for(item in projects) {
// Print errors in log


Then you don't have to do those manual steps in excel.

Obviously, this requires you to have ScriptRunner installed. Just run the code in the SR "Script Console" but make sure to test it in a test environment first!

Best regards,

Markus Fredén

This worked perfectly for me. Thank you Markus!

Like Markus Fredén likes this

Hi @Markus Fredén,


with above script if i would like to do only for few projects based on list?


@Markus Fredén - 


def projects = projectManager.getProjects()


The above code is giving me all projects in jira.

If we have only 10 projects to be updated, how can we define the list? I have the names of all 10 projects.



When I need to do this, I open in excel the list of project keys (copy and paste from admin page), then build a lot of curl commands that put a group in a role for a single project.

Repeat this command for every project:

curl -i -H 'Content-Type: application/json' -X POST -d '{"group": ["GroupName"]}' -u username:password https://<jiraurl>/rest/api/latest/project/<projectKey>/role/<roleId>

Suggest an answer

Log in or Sign up to answer

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