Kev*_*ash 0 python-jira jira-rest-api
我正在尝试使用 python 查询和拉取更改日志详细信息。
下面的代码返回项目中的问题列表。
issued = jira.search_issues('project= proj_a', maxResults=5)
for issue in issued:
print(issue)
Run Code Online (Sandbox Code Playgroud)
我正在尝试传递在上述问题中获得的值
issues = jira.issue(issue,expand='changelog')
changelog = issues.changelog
projects = jira.project(project)
Run Code Online (Sandbox Code Playgroud)
尝试上述操作时出现以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
任何人都可以就我哪里出错或我需要什么权限提出建议。
请注意,如果我issue_id在上面的代码中传递一个特定的,它工作得很好,但我试图传递一个列表issue_id
您已经可以在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()
Run Code Online (Sandbox Code Playgroud)
只是为了解释在迭代每个问题之前你做错了什么:你必须使用issue.key,而不是它issue-resource本身。当您简单地传递 时issue,它不会作为 jira.issue() 中的参数正确处理。相反,通过issue.key:
for issue in issues:
print(issue.key)
myIssue = jira.issue(issue.key, expand='changelog')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2332 次 |
| 最近记录: |