List all the issues of a project with JIRA Python

Hello all,

 

All the question is in the title, how to list ALL the issues of a project with JIRA python ?

Actually i've done this code :

def simple_issue(projects):

    i = jira.search_issues('issuetype=Bug', maxResults=None)

    print(i)

But it list only 50 issues or less. It is due to the fact that issues during the search are shown by pages containing each 50 issues and the python package cannot access to the next pages. Do you know how could i do ?

Or then not to reach has the list of issues but to reach has the list of issuetypes present in the config of the project?

3 answers

1 accepted

5 votes
block_size = 100
    block_num = 0
    while True:
        start_idx = block_num*block_size
        issues = jira.search_issues(jql, start_idx, block_size)
        if len(issues) == 0:
            # Retrieve issues until there are no more to come
            break
        block_num += 1
        for issue in issues:
            log.info('%s: %s' % (issue.key, issue.fields.summary))

it works, thank you ! 

Hi all,

I tried this code and got an error for name 'jql' 

[SOLVED]

Then later on when I'm done with this error I get a new one for 'log'

 [SOLVED]

Have you tried using maxResults=sys.maxint (or sys.maxsize if using Python 3)?

Hi,

 

see args of the function...

search_issues(jql_str, startAt=0, maxResults=50, validate_query=True, fields=None, expand=None, json_result=None)

 

use startAt and maxResults looping round incrementing StartAt by maxResults

 

wink

def simple_issue(projects):

    i = jira.search_issues("project=project_name", startAt=0, maxResults=50, validate_query=True, fields=None, expand=None, json_result=None)

print(i)

 

It list 50 issues too ...

That is because you are still specifying maxResults=50, try changing to maxResults=2000

The server won't return more than a configured number of results at most.

I believe the default is 1000.

Can you please post full python script. I am having issues getting connection 405 error.

405 has nothing to do with your script, it happens when you are attempting to pass back a file that does not have the necessary permissions on the server to receive Post information from another script.

In other words, your script is asking Jira to do something it does not have permissions to do.  Check what you are asking is correct and the user has the correct permissions

Hello Nic

 

Thanks for response

Here is the script: (I am using Jira 7.4.4 )

import httplib
import urllib
import json

conn = httplib.HTTPConnection("myjira:2002")
args = urllib.urlencode({'username':'myuser', 'password':'mypassword'})
headers = {'accept':'application/json'}
r1 = conn.request("post","/rest/auth/1/session",args, headers)

# --- Authenticate to jira ----------------
r2 = conn.getresponse()
print r1,r2.status,r2.reason,r2

 

Not sure what is wrong?

Nor do I.  405 means you don't have permission to post.  Are you sure you have the right url, the right user details and that the call you are making is supposed to be a post?  And are you sure python sends it over in the right format?

I am admin on Jira and using same credentials. Is there anyway to find out more info for  debugging.

Url is fine as I use same url for logging from browser.

 

The call I am making is a post as you can see in code

tested using postman and I get 415 error: Unsupported Meda type

 postman_img.JPG

 

used application/json (lower case A as well)

Logs atlassian-jira-security.log shows this:

http-nio-2002-exec-829 myuser 826x10767233x1 86f8ya 1yy.1xx.2xx.xxx /rest/auth/1/session The user 'myuser' has PASSED authentication.

Good morning. Looking at the response:

 i = jira.search_issues("project=project_name", startAt=0, maxResults=50, validate_query=True, fields=None, expand=None, json_result=None)

print(i)

is there a wildcard that I can use for project? Of course I tried "*" but that didn't work. I haven't been able to figure that out. Thanks.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

346 views 3 11
Read article

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