Jira Python - 所有项目的所有问题
Jira Python - all issues from all projects
我有一些代码可以通过 Jira 的 Python 客户端连接到我公司的 JIRA 服务器实例。当我对服务器中所有可用的项目进行计数时,我看到接近 4300 个项目,但是当我遍历项目以获取所有项目中所有问题的列表时,我无法获得超过 149 个项目。每个项目大约有 100 个问题,所以我预计总共有 4300 个项目和 430000 个问题。
但我得到了 149 个项目,循环存在约 27000 个问题。有没有人遇到过这个问题?这是我使用的代码:
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)
我目前没有设置来验证我的代码,但代码流应该是这样的,
首先导入所有必要的库并获取所有项目,然后
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)
几点建议:
1. 搜索问题中不需要块大小作为参数,因为默认值已设置为 50。
2. 你不必每次循环你的问题时都添加项目名称
如果结果仍然存在问题,请提供任何其他信息,例如任何错误信息、调试日志(添加一些打印语句)等,这可能会对您有所帮助。
为以下项目添加引号已解决:
import jira.client
from jira.client import JIRA
import re
import pandas as pd
options = {"server": "https://horizon.xxxxxxx.com/issues2",'verify':False}
jira = JIRA(options, basic_auth=('user','pwd'))
issues2=pd.DataFrame()
projects = jira.projects()
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
allissues = []
allissues.extend(issues)
for allissue in allissues:
d={
'projectname': projectA.key,
'key':allissue .key,
'assignee':allissue .fields.assignee,
'creator':allissue .fields.creator,
'reporter':allissue .fields.reporter,
'created':allissue .fields.created,
'components':allissue .fields.components,
'description':allissue .fields.description,
'summary':allissue .fields.summary,
'fixVersion':allissue .fields.fixVersions,
'subtask':allissue .fields.issuetype.name,
'priority':allissue .fields.priority.name,
'resolution':allissue .fields.resolution,
'resolution.date':allissue .fields.resolutiondate,
'status.name':allissue .fields.status.name,
'statusdescription':allissue .fields.status.description,
'updated':allissue .fields.updated,
'versions':allissue .fields.versions,
'watches':allissue .fields.watches,
'storypoints':allissue .fields.customfield_10002
}
issues2=issues2.append(d, ignore_index=True)
issues2.head()
您的用户是否对所有项目都有浏览权限?
是否存在不允许您查看某些问题的问题安全方案?
我有一些代码可以通过 Jira 的 Python 客户端连接到我公司的 JIRA 服务器实例。当我对服务器中所有可用的项目进行计数时,我看到接近 4300 个项目,但是当我遍历项目以获取所有项目中所有问题的列表时,我无法获得超过 149 个项目。每个项目大约有 100 个问题,所以我预计总共有 4300 个项目和 430000 个问题。 但我得到了 149 个项目,循环存在约 27000 个问题。有没有人遇到过这个问题?这是我使用的代码:
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)
我目前没有设置来验证我的代码,但代码流应该是这样的,
首先导入所有必要的库并获取所有项目,然后
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)
几点建议: 1. 搜索问题中不需要块大小作为参数,因为默认值已设置为 50。 2. 你不必每次循环你的问题时都添加项目名称
如果结果仍然存在问题,请提供任何其他信息,例如任何错误信息、调试日志(添加一些打印语句)等,这可能会对您有所帮助。
为以下项目添加引号已解决:
import jira.client
from jira.client import JIRA
import re
import pandas as pd
options = {"server": "https://horizon.xxxxxxx.com/issues2",'verify':False}
jira = JIRA(options, basic_auth=('user','pwd'))
issues2=pd.DataFrame()
projects = jira.projects()
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
allissues = []
allissues.extend(issues)
for allissue in allissues:
d={
'projectname': projectA.key,
'key':allissue .key,
'assignee':allissue .fields.assignee,
'creator':allissue .fields.creator,
'reporter':allissue .fields.reporter,
'created':allissue .fields.created,
'components':allissue .fields.components,
'description':allissue .fields.description,
'summary':allissue .fields.summary,
'fixVersion':allissue .fields.fixVersions,
'subtask':allissue .fields.issuetype.name,
'priority':allissue .fields.priority.name,
'resolution':allissue .fields.resolution,
'resolution.date':allissue .fields.resolutiondate,
'status.name':allissue .fields.status.name,
'statusdescription':allissue .fields.status.description,
'updated':allissue .fields.updated,
'versions':allissue .fields.versions,
'watches':allissue .fields.watches,
'storypoints':allissue .fields.customfield_10002
}
issues2=issues2.append(d, ignore_index=True)
issues2.head()
您的用户是否对所有项目都有浏览权限? 是否存在不允许您查看某些问题的问题安全方案?