Display other custom fields in the release notes template
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Before going through the steps below, please ensure you have successfully get the release note field works by referring to our official documentation.
The content on this page relates to velocity customization updates which are not supported by our Atlassian Support Offerings. Consequently, Atlassian can not guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
To shows other custom fields besides the text field from showhttps://developer.atlassian.com/server/jira/platform/creating-a-custom-release-notes-template-containing-release-comments/
Environment
8.20.1
Diagnosis
Users couldn't show other custom fields types such as select list, labels, and date using a similar code:
1
2
3
4
5
6
7
8
#macro (getLabel $issue $customFieldManager)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("Label"))
#if($customField.getValue($issue)) - <b>Label</b>: $textUtils.htmlEncode($customField.getValue($issue))#end
#end
#end
#end
Cause
The velocity template release note comment is made for the text custom field which causes other types of custom fields doesn't work.
Solution
For the solution here, we are adding a new custom field named "Impact". We will add a new macro (treat it as a new Java method name) with a new name getImpact() as follows:
1
2
3
4
5
6
7
8
#macro (getImpact $issue $customFieldManager)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("Impact"))
#if($customField.getValue($issue)) - <b>Impact</b>: $customField.getValue($issue)#end
#end
#end
#end
And then append the "#getImpact($issue $customFieldManager)" macro into the HTML display list:
1
2
3
4
5
6
7
8
9
10
#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)
<h2>$textUtils.htmlEncode($issueType.name)</h2>
<ul>
#foreach ($issue in $issueType.issues)
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)#getReleaseNoteComment($issue $customFieldManager)#getImpact($issue $customFieldManager)</li>
#end
</ul>
#end
#end
If you would like to add more fields, please follow the same and add a new velocity macro name to something like #get<fieldname> to get the custom field value.
After updating the changes in the html and text release note velocity files, you may want to restart JIRA to take the effects.
Was this helpful?