通过suds更新JIRA中的自定义级联选择字段

时间:2011-02-14 19:29:50

标签: jira suds python-2.7

使用JIRA版本4.2。使用Python 2.7和suds 0.4,如何更新问题的自定义级联选择字段(父级和子级)?

“Python(SOAPPy)客户端”下有一个SOAPpy example。 我使用unable to perform进行了Python JIRA CLI这种类型的更新。

实施例: 更新父级字段customfield_10的级联选择自定义子级时,可能需要更新字段customfield_10_1。

更新

显示级联字段原始值的代码:

issue = client.service.getIssue(auth, "NAHLP-33515")
for f in fields:
    if f['customfieldId'] == 'customfield_10050' or f['customfieldId'] == 'customfield_10050_1':
        print f

这导致:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

手动设置级联字段的子项后,上面的代码会产生:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }
(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = "1"
   values[] =
      "11560",
 }

上述值是我希望通过suds实现的。

请注意 key =“1”字段。键值指定此对象是customfield_10050的子对象 Documentation reference parentKey - 用于多级自定义字段,例如级联选择列表。在其他情况下为空

让我们尝试发送一个关键字段值:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "key":"1", "values":["11560"]}
                           ])

这会导致错误,因为updateIssue接受RemoteFieldValue []参数,而不是RemoteCustomFieldValue []参数(thanks Matt Doar):

suds.TypeNotFound: Type not found: 'key'

那么我们如何传递RemoteCustomFieldValue参数来更新问题呢?

更新2,mdoar的回答

通过suds追随以下代码:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "values":["11560"]}
                           ])`

价值后:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

不幸的是,这不会更新customfield_10050的子节点。手动验证。

解决:

谢谢mdoar!要更新级联选择字段的父级和子级,请使用冒号(':')指定子文件。

工作示例:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050:1", "values":["11560"]}
                           ])

1 个答案:

答案 0 :(得分:1)

相关问题