Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get all members of Jira _not_ in a particular group

My overarching task is to get all members of Jira _except those_ in a particular group, but I think I need some intermediary help before I can get there. I'm using jira-python, and I've gotten so far as to sort of get the group I need:

print jira.groups(query='jira-developers')

gives me

{u'header': u'Showing 1 of 1 matching groups', u'total': 1, u'groups': [{u'html': u'<b>jira-developers</b>', u'name': u'jira-developers'}]}

which was not the format I expected, but fine. I can't get the members of that group. The documentation seems to suggest that jira.group_members(group) should work, but I get the error that jira has no attribute group_members. Either the docs are lying or I'm an idiot, which are at least equally likely.

4 answers

1 accepted

0 votes
Answer accepted

This works fine for me:

from jira.client import JIRA

options = {'server': 'http://localhost:8080'}
basic_auth = ('admin', 'password')
jira = JIRA(options, basic_auth)

users = jira.group_members('jira-developers')
print users

N.B. You must be authenticated and have permission to run these queries.
If you're not the output of this script will give you a clue:

  • HTTP 401 "Client must be authenticated to access this resource".
    This means you're not logged in.
    Supply your credentials in 'basic_auth'.
  • HTTP 403 "You are not authorised to perform this action. Administrator privileges are required."
    The user account you used to login doesn't have the 'Browse User' permission.

Your original quest to get all user which are not in a particular group will require some scripting.
I assume all your users are in the group 'jira-users'.

  • Retrieve the members of 'jira-users' and store them in a list.
  • Retrieve the members of the group you want to exclude.
  • Delete all members of the excluded group from the jira-users list.
  • The remaining users in the list are users which are not a member of the particular group.

I'm still getting `AttributeError: 'JIRA' object has no attribute 'group_members'` from your code (obviously with my server, username and password substituted)

No, it's called something else. I created the script within sublime and I'm running it from there. Does that matter?

Wild guess: did you call your script ""?
If so, rename it to something else, delete the "jira.pyc" file, and try again.

Edit: scratch that, you would get another error.

Sorry, I don't know.
It could be a problem with your jira_python installation, but that's just a guess.

It shouldn't, but that's easy enough to try out by running the script from the commandline.

No help. Also tried typing in the same commands directly in the python prompt. Same error message: AttributeError: 'JIRA' object has no attribute 'group_members'

I have no clue.

Can you try installing Python and jira_python in a clean environment (VM or another PC) to see if that works?
If that works it proves your own installation has some problems.

It's already in a virtual environment. What was the command for getting group_members pre-6?

I'm not a regular user of jira-python, so I don't know. Have just installed and tested it for this problem.

I'm not a regular user of jira-python, so I don't know. Have just installed and tested it for this problem.

I retried, installing jira-python from scratch in a virtualenv, and everything just works out of the box.
It looks like your problem is related to your environment, but I have no clue what it could be :(

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you