I have a custom field named "Detailed Status" of the type Text Field (< 255 characters) with custom field ID value of 10000. I am writing a JIRA Python script to update the value of this custom field of a number of issues having a particular value for this field.
Lets say I want to update all the issues having the custom field value as "Test Value" with another value called, say, "New Value".
I am just getting started on JIRA Python scripting, so based on what I read on documentation, this is how my code looks like as of now.
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={'cf[10000]': 'New Value'})
This threw the following error
Traceback (most recent call last): File "test.py", line 11, in <module> issue.update(fields={ 'cf[10000]' : 'New Value'}) 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
I tried updating the custom field with its name, but couldnt get it working too. Could you please tell me the correct syntax/way to update a custom field through Jira Python script? Couldnt find any examples in the documentation as well.
Community moderators have prevented the ability to post new answers.
Hi,
I haven't used jira python myself but I can't help thinking that python interprets your "cf[10000]" as a reference to the 10000th element of a list.
From what I can gather customfields should be referenced to as "customfield_10000".
See http://jira-python.readthedocs.org/en/latest/#jirashell and https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues#JIRARESTAPIExample-Editissues-Exampleofupdatingmanyfieldsatthesametime for more info.
Thanks a lot, Daniel. It was indeed the solution.
This worked
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'})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, Daniel. That was indeed the solution.
This worked.
from jira.client import JIRA jira_options={'server': 'http://localhost:8080'} jira=JIRA(options=jira_options,basic_auth=('rrahman','nike246')) for issue in jira.search_issues(' cf[10000] ~ "Test Value" '): issue.update(fields={'customfield_10000': 'New value'})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.