Here at Isos Technology, we've seen use cases for so many different scenarios! One that comes up now and then for both my clients (and myself, as an admin) is identifying all the projects where a specific project role is being used. Whether we're auditing permissions or looking to deprecate a role, we need to know who is using the role and if it can it be consolidated with another role.
Going through projects one by one to gather this information would take a heck of a long time, so in this blog post, I will show you how to utilize a simple Groovy script in order to quickly identify all projects using a project role. To run it, just pull up a Groovy console in Jira (note that a Groovy console comes with some typical apps like JMWE and may not be available out-of-the-box).
Let's jump right in:
As you can see from above, we use the ProjectManager and ProjectRoleManagers from the Jira API to iterate over all project roles in each project to see if the name matches the role we are looking for. In our example above, this is the project role "Developers." You can edit the script to find the specific project role you need. After it's found, it outputs the information along with which users OR groups are in that project role. Obviously, the output format can be changed to be more valuable for whatever you are trying to measure.
For now, though, here's a sample output generated from the script above:
And voilà! It's as simple as that! As you can see, the script outputs not only each project that is utilizing the project role, but which users or groups are utilizing that role within each project. I hope these script snippets can help speed your admin tasks or client needs.
And as always, happy automating!