Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jira python customfield

How do you determine the name of a custom field in jira-python?

When I retrieve an issue, my custom fields show up as customfield_xxx

The names on my screen are 'project', 'name', 'due date', etc. Short of putting a value in each field, then seeing where it appears when I re-read the issue.

That is I can put 'a' in one of my fields, then read the issue, and find that customfield_10801 (or whatever) has the value 'a'. But is there a general way to find, for example, if my custom field is 'due date', which customfield_xxx does it get mapped to?

Or, in the JIRA GUI, how would I look up these customfield #'s.

like image 314
Paul Nelson Avatar asked Nov 19 '14 22:11

Paul Nelson


1 Answers

From the GUI you can see the custom field id in the html code or url:

  • On the admin page where all the custom fields are listed on the row of the custom field you are interested to the right click the gear and click/hover over "Configure". You should see the custom field ID in the URL.

Another way is via the REST API:

  • {jira-base-url}/rest/api/2/field
  • It's a GET request so just put that url in your browser.

Update:

Based on the comments it can be done something like this:

# Fetch all fields
allfields=jira.fields()
# Make a map from field name -> field id
nameMap = {field['name']:field['id'] for field in allfields}
# Fetch an issue
issue = jira.issue('ABC-1')
# You can now look up custom fields by name using the map
getattr(issue.fields, nameMap[custom_name])
like image 99
LukeSolar Avatar answered Oct 06 '22 19:10

LukeSolar