JIRAのリリースノートのカスタマイズ
運用にあわせてJIRAで作成できるリリースノートを以下のようにカスタマイズしました。
- 課題タイプが"タスク"の課題は表示しない
- 解決状況が"修正済み"以外の課題は表示しない
- コンポーネント名を表示する
Creating a Custom Release Notes Template Containing Release Comments - JIRA 4.1 - Atlassian Documentation - Confluence
リリースノートのカスタマイズ方法はこのページのとおりです。このページのサンプルではリリースノート用コメントのためのフィールドを追加しています。
テンプレートの作成
上記ページのサンプルか atlassian-jira/WEB-INF/classes/templates/jira/project/releasenotes/ 配下にあるデフォルトのvmファイルもとにVelocityのテンプレートを作成します。HTML用とテキスト用をそれぞれ作成します。私は、デフォルトのvmを使いました。私の修正したvmファイルは以下のとおりです。ファイルの文字コードはUTF-8にしておきます。
<title>$textUtils.htmlEncode($action.getText('release.notes.text.title', $project, $version))</title> <body> <table> <tr> <td> <a href="$!appProps.getString('jira.baseurl')/secure/ConfigureReleaseNote.jspa?projectId=${versionObj.projectObject.id}&version=${versionObj.id}">$action.getText('releasenotes.configure')</a> #foreach ($issueType in $issueTypes) #if($issueType.issues.size() > 0 && !$issueType.name.equals("タスク")) <h2>$textUtils.htmlEncode($issueType.name)</h2> <ul> #foreach ($issue in $issueType.issues) #set ($resolution = $issue.getResolutionObject()) #set ($status = $issue.getStatusObject()) ## check for resolved or closed and fixed #if (($status.getId() == "5" || $status.getId() == "6") && $resolution.getId() == "1") <li>[<a href='$!appProps.getString("jira.baseurl")/browse/$issue.key'>$issue.key</a>] - [#foreach($component in $issue.components)#if($velocityCount>1), #end$component.name#end] $textUtils.htmlEncode($issue.summary)</li> #end #end </ul> #end #end </td> </tr> <tr> <td> <hr width="100%"> <a name="editarea"><h2>$action.getText('release.notes.edit.copy')</h2></a> <p>$action.getText('release.notes.description')<br></p> <textarea rows="40" cols="120"> $action.getText('release.notes.heading', $project, $version) #foreach ($issueType in $issueTypes) #if($issueType.issues.size() > 0 && !$issueType.name.equals("タスク")) ** $textUtils.htmlEncode($issueType.name) #foreach ($issue in $issueType.issues) #set ($resolution = $issue.getResolutionObject()) #set ($status = $issue.getStatusObject()) #if (($status.getId() == "5" || $status.getId() == "6") && $resolution.getId() == "1") * [$issue.key] - [#foreach($component in $issue.components)#if($velocityCount>1), #end$component.name#end] $textUtils.htmlEncode($issue.summary) #end #end #end #end </textarea> </td> </tr> </table> </body>
velocity.propertiesの修正
vmファイルのエンコーディングは、ISO-8859-1になっているので、vmファイルに直接日本語を書いても正常に処理されません。atlassian-jira/WEB-INF/classes/elocity.propertiesで"UTF-8"に変更しました。
#---------------------------------------------------------------------------- # T E M P L A T E E N C O D I N G #---------------------------------------------------------------------------- input.encoding=UTF-8 output.encoding=UTF-8
今回はタスクを表示しないために、vmファイル内で"タスク"と直書きしていますが、うまくやれば直書きしなくてもよいはずなので、そうすればこの変更は不要になるので要調査。
vmファイルの編集はトライ&エラーになるので、vmファイルのキャッシュは無効にしておいた方がよいかもしれません。
class.resource.loader.cache=false
jira-application.propertiesの修正
atlassian-jira/WEB-INF/classes/jira-application.properties の以下の部分で作成したテンプレートを指定します。
# These list the templates that can be used for generating changlogs. # For each template, there needs to a corresponding entry in *both* properties jira.releasenotes.templatenames = Html, Text jira.releasenotes.templates = releasenotes-html.vm, releasenotes-text.vm # The default relaese note format jira.releasenotes.default = Text
jira.releasenotes.templatesで指定した一つめがHTMLで二つめがテキスト用として認識されるようです(jira.releasenotes.templatenamesの記述順)。
JIRA再起動
設定を有効にするためにJIRAを再起動します。