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

Is there a way to copy a user access group?

Esther Strom Community Leader Mar 09, 2020

Up until recently, our Cloud instance was open (to logged-in users). We want to keep our information transparent, and many of our users work in multiple projects.

However, we recently added a team that's part of the organization, but kind of standalone, and we do not want them to be able to see our other projects.

I'm planning on updating our default permission scheme to use a project role for Browse Projects, but don't want to have to update 40+ separate projects with individual users. Ideally, those 40+ projects would have a project role containing a group that in turn contains all users except the new team.

Therein lies the issue: we have almost 500 users in our default access group. What I now need to do is create a copy of that group with 475 users. It would be much easier if I could create a copy of our default group and then just remove the users in question, but I'm not aware of a way to do that. I'm happy to work with the REST API if necessary, since this is going to be a one-off. I'm also happy to temporarily install an add-on if there's one available that will do this.

Any ideas?

2 answers

1 accepted

0 votes
Answer accepted

Hello @Esther Strom

Thank you for reaching out.

Indeed, I'm afraid Jira does not have an Inbuilt functionality to copy users from one group to another. We have two feature requests that would allow you to configure it:

Improve Add Users To Group Functionality 

Copy all users from a group 

Feel free to vote and watch the suggestion to increase its priority and also receive notifications about any updates.

As a workaround, you can create a REST API Script to bulk add your users. These would be the exact steps:

1 - Navigate to your User management > In the Users tab, click in the button "Export Users"

2 - Select the group you want to export the users from and finish the export:

Screen Shot 2020-03-10 at 18.10.35.png

3 - Create a new group in Jira

4 - Create a script using the post command in Jira Cloud REST API to add those users to the new group you created, preferably using a practical text editor that will place that call together with the users you exported:

POST https://yourdomain.atlassian.net/rest/api/3/group/user

Let us know if you have any questions.

Thanks, @Petter Gonçalves

I figured that was the case, but hoped there was something hidden somewhere that would let me do it. API it is.

Like Petter Gonçalves likes this

Does this work for more than 50 users at a time?

#region Login
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$user = Read-Host -Prompt 
'Input an Admin name: '
$pass = Read-Host -Prompt 'Input the Admin key: '
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}  
#endregion Login

#region remove file
$FileName = ".\users.csv"
if (Test-Path .\*.csv) 
{  
Remove-Item .\*.csv
}
#endregion remove file

#region get id's from group
$groupFrom = Read-Host -Prompt 'Input group name to copy users from '
$groupMembers = [uri]::EscapeUriString($groupFrom)

$URL = "https://<>.atlassian.net/rest/api/3/group/member?groupname=$groupMembers"

do{
    $x = (((Invoke-WebRequest -UseBasicParsing -Method GET -Uri $URL -Headers $headers -SessionVariable session -ContentType 'application/json').Content) | ConvertFrom-Json)
    Out-File -FilePath $FileName -InputObject $($x.values.accountId) -Append
      if($x.isLast -ne "true"){
        $URL = $x.nextPage
        $x1 = (((Invoke-WebRequest -UseBasicParsing -Method GET -Uri $URL -Headers $headers -SessionVariable session -ContentType 'application/json').Content) | ConvertFrom-Json)        
Out-File -FilePath $FileName -InputObject 
$($x1.values.accountId) -Append
}  
}
while($x.isLast -ne "true")
#endregion get id's from group

#region copy to group
$groupTo = Read-Host -Prompt 'Input group name to copy users to '
$group = [uri]::EscapeUriString($groupTo) 

$FileName = Get-Content users.csv

foreach ($ID in $FileName) {
Invoke-WebRequest -Headers $headers -Method POST -Body (@{"accountId"="$($ID)";}|ConvertTo-Json) -Uri https://<>.atlassian.net/rest/api/3/group/user?groupname=$group -ContentType application/json
}
#endregion copy to group
exit

Here's a powershell script I've written up which does the trick for me. Simply just prompts the user for a group name and then grabs the ID's from that group to a file named "users.csv" in the same directory. It will then prompt for the group to add the users to and iterate over the file one by one. Hope this helps someone.

Suggest an answer

Log in or Sign up to answer
TAGS

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