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

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

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]

Solved how?

Like Coralie Aubert likes this

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

import sys ?

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 ...

Jeff Atlassian Team Oct 03, 2016

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.

Nic Brough Community Leader Jan 26, 2018

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?

Nic Brough Community Leader Jan 26, 2018

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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

972 views 7 0
Join discussion

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