简体   繁体   中英

How do I get the 'Resolution' from Jira with python and XML-RPC

I'm using python to fetch issues from Jira with xml-rpc. It works well except it is missing the 'Resolution' field in the returned dictionary. For example 'Fixed', or 'WontFix' etc.

This is how I get the issue from Jira:

import xmlrpclib

s = xmlrpclib.ServerProxy('http://myjira.com/rpc/xmlrpc')
auth = s.jira1.login('user', 'pass')
issue = s.jira1.getIssue(auth, 'PROJ-28')

print issue.keys()

And this is the list of fields that I get back:

['status', 'project', 'attachmentNames', 'votes', 'updated', 
 'components', 'reporter', 'customFieldValues', 'created', 
 'fixVersions', 'summary', 'priority', 'assignee', 'key', 
 'affectsVersions', 'type', 'id', 'description']

The full content is:

{'affectsVersions': [{'archived': 'false',
                      'id': '11314',
                      'name': 'v3.09',
                      'released': 'false',
                      'sequence': '7'}],
 'assignee': 'myuser',
 'attachmentNames': '2011-08-17_attach.tar.gz',
 'components': [],
 'created': '2011-06-14 12:33:54.0',
 'customFieldValues': [{'customfieldId': 'customfield_10040', 'values': ''},
                       {'customfieldId': 'customfield_10010',
                        'values': 'Normal'}],
 'description': "Blah blah...\r\n",
 'fixVersions': [],
 'id': '28322',
 'key': 'PROJ-28',
 'priority': '3',
 'project': 'PROJ',
 'reporter': 'myuser',
 'status': '1',
 'summary': 'blah blah...',
 'type': '1',
 'updated': '2011-08-18 15:41:04.0',
 'votes': '0'}

When I do:

resolutions = s.jira1.getResolutions(auth ) 
pprint.pprint(resolutions)

I get:

[{'description': 'A fix for this issue is checked into the tree and tested.',
  'id': '1',
  'name': 'Fixed'},
 {'description': 'The problem described is an issue which will never be fixed.',
  'id': '2',
  'name': "Won't Fix"},
 {'description': 'The problem is a duplicate of an existing issue.',
  'id': '3',
  'name': 'Duplicate'},
 {'description': 'The problem is not completely described.',
  'id': '4',
  'name': 'Incomplete'},
 {'description': 'All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.',
  'id': '5',
  'name': 'Cannot Reproduce'},
 {'description': 'Code is checked in, and is, er, ready for build.',
  'id': '6',
  'name': 'Ready For Build'},
 {'description': 'Invalid bug', 'id': '7', 'name': 'Invalid'}]

The Jira version is v4.1.1#522 and I using Python 2.7.

Any ideas why I don't get a field called 'resolution'?

Thanks!

The answer is that the getIssue method in JiraXmlRpcService.java calls makeIssueStruct with a RemoteIssue object. The RemoteIssue object contains the Resolution field, but makeIssueStruct copies only values that are set. So if Resolution is not set, it won't appear in the Hashtable there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM