メールのコンテンツのカスタマイズ
JIRA はテンプレートエンジンを使用したイベントに反応して電子メールを生成します。テンプレートエンジンは Apache のVelocity です。これは java オブジェクトを便利な方法で引き離すことができる、比較的使いやすいテンプレート言語です。イベントに対する関連性のオブジェクトのセットを使用して Velocity を呼び出すことで、JIRA 内でメールが生成されます。
注意:
- To change the columns in your filter subscriptions, you don't need to customise the mail templates. See Customising your Issue Navigator.
- JRA-7266 にはこの改善に対するよう要求リクエストがあり、この実装のチャンスを改善するよう投票できます。
- Bear in mind that the next time you upgrade JIRA – or need a new installation for any reason – you will have to manually copy any changes you have made to Velocity templates (as well as JSPs) into the new installation of JIRA. If the Velocity templates and/or JSPs have changed in the newer version, you will have to manually port your customisations into them (as opposed to copying these files directly over from your old JIRA installation to your upgraded one).
Customisations to Velocity templates or other JIRA files are not included in the scope of Atlassian Support.
メール テンプレートの場所
To customise email content, please follow this procedure.
- JIRA ディストリビューションを開き、次のパスに移動します。
- The
WEB-INF/classes/templates/email/of the<jira-application-dir>in your JIRA Installation Directory. - The
jira/src/etc/java/templates/email/in your extracted JIRA source directory.
- The
- このディレクトリには、
html、text、およびsubjectの 3 つのディレクトリがあります。htmlサブディレクトリには html 形式でメールを作成するために使用するテンプレートが含まれ、textディレクトリにはプレーン テキスト メール出力が含まれます。subjectディレクトリにはメールの件名を生成するために使用されるテンプレートが含まれます。テンプレートには、メールをトリガーするイベントに関連する名前が設定されます。 - Bring the template up in your favourite text editor. Referring to the JIRA template documentation (particularly Velocity Context for Email Templates) and Velocity Users Guide, make the customisations you want.
- Jira を再起動します。
新しい電子メールテンプレートの場合:
html、text、およびsubjectディレクトリで、それらのディレクトリ内の既存のファイルに基づき、新しくmytemplate.vmファイルを作成します。- テンプレートを
atlassian-jira/WEB-INF/classes/email-template-id-mappings.xmlに追加して、新しいイベントを追加する際に選択できるようにします。
Note that since JIRA 4.1 each new template has to have a corresponding file in the subject directory.
Advanced customisation
issue オブジェクトは vm テンプレートに渡されます。これに関連する /includes/summary-topleft.vm 内の複数の実装に注意します。例として、$issue.getProject() を呼び出すと、課題が所属するプロジェクトを決定し、別のプロジェクトからのメールでは異なる情報を表示するロジックを作成することもできます。
JIRA を再起動せずに Velocity テンプレートを展開する
In a development instance, you can play with picking up velocity file changes without a restart.
From <jira-install>/atlassian-jira/WEB-INF/classes/velocity.properties:
class.resource.loader.cacheをtrueからfalseに変更します。#velocimacro.library.autoreload=trueからコメント記号 (#) を削除します。
Making this change in production will eventually lead to JIRA not serving pages along with the ran out of parsers error in the log file.
また、「電子メールにカスタムを追加する」も参照してください。