Use curl in a Linux Bash script:
#!/bin/bash
admin_user=fu
admin_password=bar
jira_server="https://jira.acme.com"
api_version=2
url_part2="/rest/api/${api_version}/field"
curl -k -u ${admin_user}:${admin_password} -X GET -H "Accept: application/json" ${jira_server}${url_part2} \
| jq '.' > raw_file.json
# Extract field names, remove double quotes, sort
cat raw_file.json | jq '.[].name' | sed 's/"//g' | sort > nice_file.txt
Note: There is a separate REST-API to get only custom fields, but it's not working for me at this time. I will update once I find a solution.
1. The REST-API for Jira Server does not support getting only the custom fields.
Your recourse is to check the "id" key in the JSON (the file raw_file.json). If the value is "customfield_nnnnn", it's a custom field. Or, even simpler, you can check the key "custom" which is "true" for custom fields.
2. When you view the fields in the Jira UI
https://jira.acme.com/secure/admin/ViewCustomFields.jspa
there may be fields which are marked Not configured for any context under the Available context(s) column.
I've found out that the REST-API call does not retrieve these fields.
Amir Katz (Outseer)
Technical Lead
Outseer, an RSA company
Israel
19 accepted answers
1 comment