We're in the process of migrating from Bugzilla to JIRA. In our Bugzilla instance, we have a custom drop-down field that lists a bunch of versions. That gets imported fine but as a JIRA custom drop-down. What I'd like to do, for each issue, is that the value of custom drop-down and put it in a new "version picker" custom field. I'm trying to use the jira-python client to do this but running into problem. See the code below. it doesn't error out when I do this but it's not updating the new version picker field. Any thoughts?
jira = JIRA({'server': DEFAULT_JIRA_SERVER}, basic_auth=(DEFAULT_JIRA_USER, DEFAULT_JIRA_PASS)) issues_to_mod = jira.search_issues('filter=filter_alerts', maxResults=200) print 'Will update', str(len(issues_to_mod)), 'issues.' for issue in issues_to_mod: old_fixed_version = issue.fields.customfield_10105 old_fixed_version_string = str(old_fixed_version[0]) print 'Updating issue', issue, 'with value', old_fixed_version_string issue.update(fields={'customfield_10400': {'value': old_fixed_version_string}})
Huzzah!! My original code sample was correct except for one word: "value" needed to be replaced with "name". So the correct code is:
jira = JIRA({'server': DEFAULT_JIRA_SERVER}, basic_auth=(DEFAULT_JIRA_USER, DEFAULT_JIRA_PASS)) issues_to_mod = jira.search_issues('filter=filter_alerts', maxResults=200) print 'Will update', str(len(issues_to_mod)), 'issues.' for issue in issues_to_mod: old_fixed_version = issue.fields.customfield_10105 old_fixed_version_string = str(old_fixed_version[0]) print 'Updating issue', issue, 'with value', old_fixed_version_string issue.update(fields={'customfield_10400': {'name': old_fixed_version_string}})
For those who care, I figured it out by looking at the REST examples here. Each custom field type has a specific data structure. In the case of version-picker fields, the value can be referenced by either the version "name" or "id".
for user-selector custom fields, with their username:
issue.update(fields={'customfield_10000': {'name': userid}})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! I was totally lost with "how to set Multiselect" custom field using Python Jira.
I had a look the REST examples you pointed and found a solution (setting Multiselect requires data in array)
like this
issue.update(fields={'customfield_10007': [{'value':'035M'}]})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ping...
Anyone? It's frustrating because the code "works" in the sense that it exits with 0. It's just the field is not getting updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Sorry for late answer.
Don't you need to create version object using jira.create_version()? That is what needs to be done when using JIRA from browser.
BR
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Thierry. I got it figured out (see above). To answer your question, we shouldn't need to create a version object since it's already there (the versions were imported as a part of the BZ import process). What I'm doing here is basically converting that object name (the version) into a string and then assigning that string as a value to the custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.