2013-03-25 45 views
0

我有命名的自定義字段「詳細狀態」的類型文本字段的(< 255個字符)與10000搜索和更新基於自定義字段 - 吉拉的Python

我自定義字段ID值我正在編寫一個JIRA Python腳本來更新此字段中具有特定值的許多問題的此自定義字段的值。

可以說,我想更新具有叫,說一個值,「新價值」自定義字段值「測試值」的所有問題。

我剛剛開始使用JIRA Python腳本,因此根據我在documentation上閱讀的內容,這就是我的代碼現在的樣子。

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[10000] = "Test Value" ', maxResults=3): 
    issue.update(fields={'Detailed Status': 'New Value'}) 

但是,我得到以下錯誤。

File "test.py", line 10, in <module> 
    for issue in jira.search_issues(' cf[10000] = "Test Value" ', maxResults=3): 

    File "C:\Python27\lib\site-packages\jira\client.py", line 1000, in search_issues 
    resource = self._get_json('search', search_params) 
    File "C:\Python27\lib\site-packages\jira\client.py", line 1396, in _get_json 
    raise_on_error(r) 
    File "C:\Python27\lib\site-packages\jira\exceptions.py", line 36, in raise_on_ 
error 
    raise JIRAError(r.status_code, error, r.url) 
jira.exceptions.JIRAError: HTTP 400: "Field 'cf[10000]' is not searchable, it is 
only sortable." 
http://localhost:8080/rest/api/2/search?jql=+cf%5B10000%5D+%3D+%22Test+Value%22+ 
&startAt=0&maxResults=3 

我也試圖與cf[10000] ~ 'Test Value',但它給了同樣的錯誤如上。

你能告訴我我可能會做錯什麼嗎?

回答

1

當您定義自定義字段時,您是否爲其啓用了搜索器?這可能是問題所在,根據錯誤消息

+0

這確實是解決方案。謝謝@mdoar! – ramz 2013-03-26 05:15:09

0

只要在我爲自定義字段啓用搜索器後添加適用於我的代碼,就像上面@mdoar給出的答案一樣。

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[10000] ~ "Test Value" '): 
    issue.update(fields={'customfield_10000': 'New value'}) 
相關問題