SQL for list of users JIRA project

avinash bhatt March 18, 2015

Hi

 

Please help....can i get a sql for to retrieve list of users in a JIRA project

3 answers

0 votes
Pablo Beltran
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2015

The SQL for JIRA plugin can answers to this question in an straightforward way:

The query below shows all the actors (users playing a role) in a project

SELECT * FROM PROJECTROLEACTORUSERS

Therefore, you might want to run:

SELECT * FROM PROJECTROLEACTORUSERS WHERE ROLENAME='jira-developers'

Furthermore, SQL for JIRA is fully integrated with JIRA security and permissions, so each users would see his roles only. Of course, JIRA administrators would see the roles for everybody on each project.

0 votes
avinash bhatt March 18, 2015

why - that is an interesting question.  Our current instance of JIRA is used by few departments and as we are planning to move over to cloud, we have been asked by folks who control the money, to identify user, project so that we could get funding from all stake holders

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2015

Depends on your user directory, but there's no easy SQL to get it even in the internal directory.

First, what do you define as a "user of a project"?  Someone who can see it?  Or someone who can create issues in it?  Or they can be assigned issues?  And so-on.

Then you need to read your permission scheme to find out the rules set to determine that "is a user".  For example, if your rule is "can create issues, or can be assigned issues", then you need the rules set for "Create" and "Assignable user".

Those rules could be quite simple - "group X" or "user Y", but it's quite likely that they are more flexible than that, so they'll say "role Z" or "reporter" or or or or...

So you then need to interpret those rules to get back to a set of users.  If it's "group X", then you can simply read cwd_membership for the user ids in the group.  But if it's "role X", then you'll need to read the project role for the users in that role and the groups, then go into the groups to get the users.

In short, you have a big task in front of you, and we can't even begin to help you with raw SQL until you have a hard rule for "is a user in a project"

avinash bhatt March 18, 2015

Thanks for your response Nic

 

Any user who has permissions on the project (as Admin or anyother) is how i would classify a user.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2015

Ok, that's good because it's clear, but potentially complex because you'd need to read the entire permission scheme for every rule. I'd dodge that and just look at the "browse" permission in the scheme if you need a simple view - it's technically wrong, but it's rare that you'd have a user who can do things in a project but not actually see the issue! So, you'll need to read schemepermission to get the list of groups, roles, reporter, assignee, customfield etc for "Browse project", then read the appropriate tables for each of those - reporter and assignee are on jiraissue, the groups are in cwd_membership, the roles are in projectrole, join that to projectroleactor to get the lists of groups and users in the roles etc. Maybe it's easier to ask *why* you're trying to do this? And maybe why you're choosing the hard way?

Suggest an answer

Log in or Sign up to answer