I have some code to connect to my company’s instance of the JIRA server via Jira’s Python Client. When i do a count on all the projects available in the server, I see close to 4300 projects, but when I loop through the projects to get a list of all the issues in all the projects, I cannot get more than 149 projects. There are about 100 issues in each project so I’d expect a total of 4300 projects and 430000 issues. But I’m getting 149 projects and the loop exists with ~27000 issues. Has anyone faced this problem? Here’s the code I’m using:
import jira.client
from jira.client import JIRA
import re
import pandas as pd
options = {"server": "https://horizon.xxxxxx.com/issues",'verify':False}
jira = JIRA(options, basic_auth=('user','pwd'))
projects = jira.projects()
allissues = []
allprojects=[]
block_size=50
for projectA in projects:
block_num=0
while True:
start_idx=block_num*block_size
issues=jira.search_issues(f'project = {projectA.key}', start_idx, block_size)
if len(issues)== 0:
break
block_num+=1
for issue in issues:
allissues.append(issue)
allprojects.append(projectA.key)
I don't the setup to currently validate my code, but the code flow should be looking like this,
First import all your necessary libraries and get all the projects, then
projectsList=[]
issuesList=[]
for proj in projects:
while true:
startIndex=block_num*block_size
issues=jira.search_issues(f'project = {projectA.key}', start_idx
if len(issues)== 0:
break
block_num+=1
issueList.extend(issues)
projectsList.append(proj)
Few pointers: 1. Block size is not needed in search issues as argument because by default value is already set at 50. 2. You don't have to add project name every time you loop your issue
If you there are still issues with the results, then do provide any additional information such as any error info, debug logs (add some print statements) etc., that might help in helping you.