更新选择列表自定义字段 - Jira Python

ram*_*amz 4 python jira jira-rest-java-api

我有一个名为“ Status ”的自定义字段,ID 为 10100,它是一个选择列表,可选值为“ One ”、“ Two ”、“ Three ”和“ Four ”。默认值为“”。

我正在编写一个 JIRA python 脚本来有条件地更新该字段的值。假设现有值为“”,则应将其更改为“”。

这是我的代码。

from jira.client import JIRA
jira_options={'server': 'http://localhost:8080'}
jira=JIRA(options=jira_options,basic_auth=('usrname','pwd'))

for issue in jira.search_issues(' cf[10100] = "One" '):
    issue.update(fields={'customfield_10100': 'Two'})
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误。

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    issue.update(fields={'customfield_10100': 'Two'})
  File "C:\Python27\lib\site-packages\jira\resources.py", line 193, in update
    super(Issue, self).update(**data)
  File "C:\Python27\lib\site-packages\jira\resources.py", line 72, in update
    raise_on_error(r)
  File "C:\Python27\lib\site-packages\jira\exceptions.py", line 29, in raise_on_
error
    error = errorMessages[0]
IndexError: list index out of range
Run Code Online (Sandbox Code Playgroud)

你能告诉我可能出了什么问题吗?我使用相同的语法来编辑文本字段类型的自定义字段,并且效果很好。

小智 5

试试这样:

issue.update(fields={'customfield_10100': {'value':'Two'}})
Run Code Online (Sandbox Code Playgroud)

或者像这样:

issue.update(fields={'customfield_10100': {'value','Two'}})
Run Code Online (Sandbox Code Playgroud)

我不确定哪一个适合你,因为我从未使用过 Python,但其中之一应该可以。