我正在尝试使用python查询和提取变更日志详细信息。
下面的代码返回项目中的问题列表。
issued = jira.search_issues('project= proj_a', maxResults=5)
for issue in issued:
print(issue)
我正在尝试传递在上述问题中获得的值
issues = jira.issue(issue,expand='changelog')
changelog = issues.changelog
projects = jira.project(project)
尝试以上操作时出现以下错误:
JIRAError: JiraError HTTP 404 url: https://abc.atlassian.net/rest/api/2/issue/issue?expand=changelog
text: Issue does not exist or you do not have permission to see it.
任何人都可以告知我哪里出了问题或需要什么权限。
请注意,如果我在上面的代码中传递了特定的issue_id
,则可以正常工作,但我正在尝试传递issue_id
的列表
答案 0 :(得分:0)
您已经可以在search_issues方法中接收所有变更日志数据,因此您不必通过遍历每个问题并为每个问题进行另一个API调用来获取变更日志。请查看以下代码,获取有关如何使用变更日志的示例。
issues = jira.search_issues('project= proj_a', maxResults=5, expand='changelog')
for issue in issues:
print(f"Changes from issue: {issue.key} {issue.fields.summary}")
print(f"Number of Changelog entries found: {issue.changelog.total}") # number of changelog entries (careful, each entry can have multiple field changes)
for history in issue.changelog.histories:
print(f"Author: {history.author}") # person who did the change
print(f"Timestamp: {history.created}") # when did the change happen?
print("\nListing all items that changed:")
for item in history.items:
print(f"Field name: {item.field}") # field to which the change happened
print(f"Changed to: {item.toString}") # new value, item.to might be better in some cases depending on your needs.
print(f"Changed from: {item.fromString}") # old value, item.from might be better in some cases depending on your needs.
print()
print()
仅在解释每个问题之前先解释一下您做错了什么:您必须使用issue.key
而不是issue-resource
本身。当您简单地传递issue
时,它将不会正确地作为jira.issue()中的参数进行处理。相反,请传递issue.key
:
for issue in issues:
print(issue.key)
myIssue = jira.issue(issue.key, expand='changelog')