如何通过Python和XML-RPC从Jira获取“分辨率”?

0 投票
1 回答
1420 浏览
提问于 2025-04-17 00:10

我正在用Python通过xml-rpc从Jira获取问题信息。这个方法运行得很好,但返回的数据里缺少了“解决方案”这个字段,比如“已修复”或者“不会修复”等等。

这是我从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()

而这是我得到的字段列表:

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

完整内容是:

{'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'}

当我执行:

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

我得到的是:

[{'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'}]

我使用的Jira版本是v4.1.1#522,Python版本是2.7。

有没有人知道为什么我没有得到一个叫“resolution”的字段呢?

谢谢!

1 个回答

2

这个答案是说,在JiraXmlRpcService.java文件里,getIssue这个方法会调用makeIssueStruct,并传入一个RemoteIssue对象。这个RemoteIssue对象里面有一个叫做Resolution的字段,但makeIssueStruct只会复制那些已经设置过的值。所以如果Resolution这个字段没有被设置,它在Hashtable里就不会出现。

撰写回答