Documentation for JIRA 4.2. Documentation for other versions of JIRA is available too.
Printing a custom field in a JIRA email is fairly easy in 3.6 and above. The feature request to integrate this into JIRA is being tracked at JRA-4619.
This can be discovered from the database, or by examining the URLs of custom field pages. For example, here the id of the custom field is 10000:
If using the EAR/WAR version, make changes in the edit-webapp directory, then rebuild and re-deploy the WAR file.
Locate the Velocity template of the email type you wish to modify. For instance, you may want to modify the 'issue created' template, as well as the template reused in 'issue commented':
atlassian-jira/WEB-INF/classes/templates/email/text/issuecreated.vm
atlassian-jira/WEB-INF/classes/templates/email/text/includes/issuesummary.vm
以下のスニペットを、ファイル内の表示したい位置に追加します。
#if ($issue.getCustomFieldValue("customfield_10000")) $stringUtils.leftPad($issue.getCustomField("customfield_10000").name, $padSize): $issue.getCustomFieldValue("customfield_10000") #end
The javadoc for $stringUtils.leftPad can be found here.
In atlassian-jira/WEB-INF/classes/templates/email/text/includes/issuesummary.vm
you will want:
#if ($issue.getCustomFieldValue("customfield_10000")) >$stringUtils.leftPad($issue.getCustomField("customfield_10000").name, $padSize): $issue.getCustomFieldValue("customfield_10000") #end
Note: you need to change the custom field id to the id observed in step 1. Here it is 10000 - yours will probably be different.
If you wish to iterate over all related custom fields you can use the following example:
#foreach ($value in $customFieldManager.getCustomFieldObjects($issue)) >$stringUtils.leftPad($value.getName(), $padSize): $!value.getValueFromIssue($issue) #end
To make the changes take effect, restart JIRA. If you wish to avoid the continual restarts during testing, edit atlassian-jira/WEB-INF/classes/velocity.properties
and alter this section as the comment says:
# To enable autoreloading, set cache to false and uncomment the autoreload line class.resource.loader.cache=true #velocimacro.library.autoreload=true