列出问题创建和解决时间

时间:2016-06-10 06:41:27

标签: python jira python-jira

我试图找出如何列出他们的创作和解决时间的问题。如下所示的更改日志未列出问题和解决时间的创建时间。我该如何检索这些数据?

 #!/usr/bin/python
 import jira.client
 from jira.client import JIRA

jira = JIRA(options, basic_auth=(USERNAME, PASSWORD))

issue = jira.issue('FOO-100', expand='changelog')
changelog = issue.changelog

for history in changelog.histories:
    for item in history.items:
        if item.field == 'status':
            print 'Date:' + history.created + ' From:' + item.fromString + ' To:' + item.toString

输出:

Date:2012-10-23T09:49:41.197+0100 From:Open To:Queued
Date:2012-10-23T09:49:43.838+0100 From:Queued To:In Progress
Date:2012-10-23T09:49:45.390+0100 From:In Progress To:Blocked
Date:2012-10-29T16:06:36.733+0000 From:Blocked To:In Progress
Date:2012-10-31T16:47:40.191+0000 From:In Progress To:Peer Review
Date:2012-10-31T16:47:41.783+0000 From:Peer Review To:Customer Approval

1 个答案:

答案 0 :(得分:1)

您可以在issue.fields

中的字段中获取创建和解决日期时间 像这样:

#!/usr/bin/python
import jira.client
from jira.client import JIRA

jira = JIRA(options, basic_auth=(USERNAME, PASSWORD))

issue = jira.issue('FOO-100', expand='changelog')

creation_time = issue.fields.created
#u'2016-06-09T15:54:28.157+0000'
resolved_time = issue.fields.resolutiondate
#u'2016-06-10T07:00:13.539+0000'

注意: resolutiondate仅在问题解决后才存在,因此请在引用之前进行检查。