Hi everyone
I would like get all project use the groups
Example :
Groups Crow : test-administrators ; test-developers
Project used the groups test-administrators : Test1 and Test2
I to do this script but he don't work
Have you idea ??
Thanks in advance
Hmm, this one has thrown me a bit of a curveball.
My initial answer was going to boil down to "define 'use'", but I wanted to think about it a bit before answering, and it got complicated.
The "define 'use'" matters though - a project could be using a group in all sorts of ways. The obvious one is the stuff around permissions that I think this question is about (possibly as simple as "what groups can see this project?"?), but there's more. Do you have group-picker fields? Have you used groups in the notifications scheme? Or the security scheme? Have you used groups in the workflows?
That's not the curveball though, it's just checking I am thinking about the right question.
Assuming it is about "groups who have permissions in the projects", then there is a complexity you'll need to think about. Going back to "Can this group see the issues" as the simple example, then it is not a simple question because you could set up the "browse project" permission with:
So, the curveball is in @PD Sheehan 's code. I do not know if that drills down into the three lines above. It will either return
Where Group X has been used in the permission scheme
or
Where Group X has made its way into the permission scheme by being named directly, or by being added to a role or group-picker.
I really do hope the code there will literally return all the groups that have a permission, by whatever route, but I don't know.
Please, do let us know if it does! I'd be very grateful to find out!
(Actually, the bit about the group-picker is a bit of a red-herring, I do know how that works, and you do not want the long boring essay that ends up with "just don't use group-pickers in permission schemes, it's probably not going to do what you expect")
Yeah @Nic Brough -Adaptavist- I made some assumptions about where the OP was attempting to go based on some of the code they had already written.
Since the code was already attempting to get all the groups that have BROWSE permission, I just fixed the part of the code that was comparing the list for a given project against the group specified by the form/annotation.
But you were correct to be cautious...
It turns out that permissionManager.getAllGroups() returns only the groups added directly to the permissions scheme.
It doesn't include roles granted access via project roles.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is working for me:
import com.onresolve.scriptrunner.parameters.annotation.ShortTextInput
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.Permissions
@ShortTextInput(description = 'Select admin group to search for', label = 'Admin group')
String adminGroup
def group = ComponentAccessor.groupManager.getGroup(adminGroup)
assert group, "No group found by the name of $adminGroup"
def projects = ComponentAccessor.projectManager.projectObjects
def projectsWithGroup = []
projects.each{
def listGroups = ComponentAccessor.permissionManager.getAllGroups(Permissions.BROWSE, it)
if(listGroups.contains(group)){
projectsWithGroup.add(it)
}
}
"Projects containing $group.name: <br>${projectsWithGroup.collect{"$it.name ($it.key)"}.join('<br>')}"
But you want to look for an alternative solution since the "com.atlassian.jira.security.Permissions" is deprecated. Strangely, they've not deprecated the permissionsManager.getAllGroups method. It's the only one that still requires the Permissions class and there is no replacement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Thank for your answer but i have the errors :
Have you idea for this errrors
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code is structured incorrectly, but you have not shown us all of the code, so we can't see where the problem might be.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What errors do you get when you execute that script?
Not all errors in the editor are real. Most "static type checking" errors are just warning that the editor in unable to confirm the type of the object in question (in this case "it" an element of the projectsWithGroup) and therefore can't confirm if the property or method being called (.name and .key) is valid.
If you really want to eliminate this error, you can add
import com.atlassian.jira.project.Project
Then define the projectsWithGroup using a typed declaration:
List<Project> projectsWithGroup= []
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.