メールのコンテンツのカスタマイズ

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

JIRA はテンプレートエンジンを使用したイベントに反応して電子メールを生成します。テンプレートエンジンは Apache のVelocity です。これは java オブジェクトを便利な方法で引き離すことができる、比較的使いやすいテンプレート言語です。イベントに対する関連性のオブジェクトのセットを使用して Velocity を呼び出すことで、JIRA 内でメールが生成されます。

(info) 注意:

  • 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.

  1. 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.
  2. このディレクトリには、htmltext、および subject の 3 つのディレクトリがあります。html サブディレクトリには html 形式でメールを作成するために使用するテンプレートが含まれ、text ディレクトリにはプレーン テキスト メール出力が含まれます。subject ディレクトリにはメールの件名を生成するために使用されるテンプレートが含まれます。テンプレートには、メールをトリガーするイベントに関連する名前が設定されます。
  3. 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.
  4. Jira を再起動します。

新しい電子メールテンプレートの場合:

  1. htmltext、および subject ディレクトリで、それらのディレクトリ内の既存のファイルに基づき、新しく mytemplate.vm ファイルを作成します。
  2. テンプレートを 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:

  1. class.resource.loader.cache を true から false に変更します。
  2. #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.

また、「電子メールにカスタムを追加する」も参照してください。

最終更新日 2013 年 5 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.