You can automatically create custom fields with code within your plugin for JIRA.
Here is an example method to do this. This method creates four custom fields.
public void createAllCustomFields(){
CustomFieldType fieldType = customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:textfield");
try {
CustomField contactName = customFieldManager.createCustomField("Contact Name", "Name of the contact", fieldType , null, null, null);
customFieldManager.createCustomField("Contact Surname", "Surname of the contact", fieldType , null, null, null);
customFieldManager.createCustomField("Contact Phone", "Phone number of the contact", fieldType , null, null, null);
customFieldManager.createCustomField("Contact Email", "Email address of the contact", fieldType , null, null, null);
} catch (GenericEntityException e) {
e.printStackTrace();
}
System.out.println("createAllCustomFields is called !!!!!!!!!!!!!!!!!!!!!");
}