1

I am trying to find out how I can list issues with their creation and resolved time. The changelog as shown below does not list the creation time for the issue and resolution time. How can i retrieve that data?

 #!/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

Output:

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 Answers1

1

You can get the creation and resolution date times from their fields within issue.fields

like so:

#!/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'

Note: resolutiondate will only exist if the issue has been resolved, so check before referencing it.

KMR
  • 792
  • 13
  • 21
  • How can I find all issues for a project with their creation and resolution time? –  Jun 10 '16 at 07:53
  • To find all the issues in a project you'll need to use `search_issues`. For example, to find all the resolved issues use `issues = jira.search_issues('project=FOO AND status = "Resolved"')` – KMR Jun 14 '16 at 01:05