Enable the link in JIRA based on project role

I have made a new jira plugin which has some links enabled based on the following condition specified in atlassian-plugin.xml




But the problem here is that all the project leads need to be provided with the Admin access in JIRA.

Is there a way where i can modify the above condition and use the project role instead.

Currently following project roles are defined in projectrole table.

10000 Users A project role that represents users in a project
10001 Developers A project role that represents developers in a project
10002 Administrators A project role that represents administrators in a project
10100 leads One who has previlege to create,modify and delete
10200 RCCL Scrum Master RCCL Scrum Master
10300 Eventing Shift Leads Eventing team resource who come in shifts and support, attend incidents, etc

how can i use this information and enable the link only for role 10100 i.e leads.


Tarun Arora

1 answer

How about com.atlassian.jira.plugin.webfragment.conditions.HasProjectPermissionCondition ? It allows testing the current user for specific project permission

Here's a sample :

&lt;condition class="com.atlassian.jira.plugin.webfragment.conditions.HasSelectedProjectCondition" /&gt;
        &lt;conditions type="OR"&gt;
            &lt;condition class="com.atlassian.jira.plugin.webfragment.conditions.HasProjectPermissionCondition"&gt;
                &lt;param name="permission"&gt;project&lt;/param&gt;


This will not be feasible solution in my case.

It is something like this.

There are 4 links for my plugin. Only one of those 4 links is enabled for the developers and the other 3 should be enabled only for the leads and the administrator.

using the solution mentioned above,it will enable all the 4 links for developers,leads and administrator.

Need a solution to clearly distinguish between a developer and a lead.



The solution I offered may be used if the roles can be distinguished by permissions but that's not ideal solution if the permissions change over time. So the best will be if you implement you own condition that checks the role of a user which should be pretty straightforward

<condition class="class name">

<param name="role">lead</param>
Can we have a solution something like the above where class name has a attribute role which maps to the role in the projectrole table.
Or if there is no direct class available in Jira for the same,can u give me an example(sample code) of how to write my own custom condition to find the role of the logged in user and enable /disable the link based on his role.

Here's a sample (not tested though):

package com.myplugin.conditions;

import java.util.Map;

import com.atlassian.jira.plugin.webfragment.conditions.AbstractWebCondition;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.plugin.PluginParseException;

public class HasProjectRoleCondition extends AbstractWebCondition {

	private ProjectRoleManager roleManager;
	private ProjectRole projectRole;

	public HasProjectRoleCondition(ProjectRoleManager roleManager) {
		this.roleManager = roleManager;

	public void init(Map&lt;String, String&gt; params) throws PluginParseException {
		String roleName = params.get("role");
		projectRole = roleManager.getProjectRole(roleName);
		if (projectRole == null) {
			throw new PluginParseException("Could not determine role for: " + params.get("role"));

	public boolean shouldDisplay(ApplicationUser user, JiraHelper jiraHelper) {
		final Project project = jiraHelper.getProjectObject();
		return roleManager.isUserInProjectRole(user, projectRole, project);


and then in the atlassian-plugin.xml

&lt;condition class="com.atlassian.jira.plugin.webfragment.conditions.HasSelectedProjectCondition" /&gt;
       &lt;conditions type="OR"&gt;
           &lt;condition class="com.myplugin.conditions.HasProjectRoleCondition"&gt;
               &lt;param name="role"&gt;leads&lt;/param&gt;

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot