【问题标题】:How do I get the 'Resolution' from Jira with python and XML-RPC如何使用 python 和 XML-RPC 从 Jira 获得“解决方案”
【发布时间】:2011-08-23 10:03:01
【问题描述】:

我正在使用 python 通过 xml-rpc 从 Jira 获取问题。它运行良好,只是它缺少返回字典中的“解决方案”字段。例如“Fixed”或“WontFix”等。

这就是我从 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。

任何想法为什么我没有得到一个名为“分辨率”的字段?

谢谢!

【问题讨论】:

    标签: python xml-rpc jira


    【解决方案1】:

    答案是 JiraXmlRpcService.java 中的 getIssue 方法使用 RemoteIssue 对象调用 makeIssueStruct。 RemoteIssue 对象包含 Resolution 字段,但 makeIssueStruct 仅复制设置的值。所以如果没有设置分辨率,它就不会出现在那里的哈希表中。

    【讨论】:

    • 如果可能,我建议使用 SOAP 而不是 XML-RPC。
    • 啊……是的,当我看到有解决方案的问题时,我现在看到了。谢谢!
    猜你喜欢
    • 2020-12-01
    • 1970-01-01
    • 2022-12-01
    • 2014-12-05
    • 2022-11-11
    • 2022-11-10
    • 1970-01-01
    • 2021-07-15
    • 2022-10-13
    相关资源
    最近更新 更多