I want to show the list of all the users/group who have project-admin role on project home page, seemlier the way we have the project lead displayed. I would like to use Script Runner for this. Could you please help me with the groovy code.
Hi Manu,
You can use Script Fragments to create a web panel with the following configuration
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.PermissionManager
import com.atlassian.jira.security.Permissions
import com.atlassian.jira.security.groups.GroupManager
def project = context.project as Project
def groupManager = ComponentAccessor.getComponent(GroupManager)
def usersInGroupsWithPermissions = ComponentAccessor.getComponent(PermissionManager).
getAllGroups(Permissions.PROJECT_ADMIN, project)?.
collect { groupManager.getUsersInGroup(it)*.key }?.
flatten()?.
unique()?.
collect {userProfileLink(it)}?.
join("<br>")
writer.write "Users with Admin permissions for project $project.key <br> $usersInGroupsWithPermissions"
def userProfileLink (String userKey) {
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def displayName = ComponentAccessor.userManager.getUserByKey(userKey).displayName
"""
<a href="$baseUrl/secure/ViewProfile.jspa?name=$userKey">$displayName</a>
"""
}
The only issue is that this panel will show you only users in groups with project permissions and not users in project roles with project permissions.
Please let me know if this helps,
Thanos
Thanks Thanos, let me try this. however, most of the time individual users are assigned the project role permission under 'Users'. But let me use this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanos,
I am getting the below error while running:
com.atlassian.plugin.PluginParseException: Required resource with name 'view' does not exist.
at com.atlassian.plugin.web.descriptors.WebPanelSupplierFactory.
getRequiredViewResource(WebPanelSupplierFactory.java:107)
at com.atlassian.plugin.web.descriptors.WebPanelSupplierFactory.
build(WebPanelSupplierFactory.java:56)
at com.atlassian.plugin.web.descriptors.DefaultWebPanelModule
Descriptor.init(DefaultWebPanelModuleDescriptor.java:130)
at com.atlassian.plugin.ModuleDescriptor$init$2.call(Unknown Source)
at com.atlassian.plugin.ModuleDescriptor$init$2.call(Unknown Source)
at com.onresolve.scriptrunner.fragments.FragmentsManager.
register(FragmentsManager.groovy:258)
at com.onresolve.scriptrunner.fragments.FragmentsManager.
register(FragmentsManager.groovy)
at com.onresolve.scriptrunner.fragments.IFragmentsManager
$register.call(Unknown Source)
at com.onresolve.scriptrunner.fragments.AbstractCustomWebPanel.
doScript(AbstractCustomWebPanel.groovy:148)
at com.onresolve.scriptrunner.canned.CannedScript$doScript.call
(Unknown Source)
at com.onresolve.scriptrunner.canned.CannedScript$doScript.call
(Unknown Source)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.validate
AndRunCannedInternal(ScriptRunnerImpl.groovy:430)
at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runCanned
(ScriptRunnerImpl.groovy:376)
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.
Thanos,
I would like to return all the user names under the project role >> groups with project admin permission as a comma delimited string.
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.
@Thanos Batagiannis [Adaptavist] Can you please update. If i am using the method "getAllGroups" than should i use the (Permission ID[int]). If yes, than in my initial query, i want to show the list of users/groups under role project Admin(10050). Can you please modify an above query.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thanos Batagiannis [Adaptavist]
Can you send us sample screenshot of the output for this web panel?
Thanks
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.