Customizing Email Content

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

(info) 注意:

  • To change the columns in your filter subscriptions, you don't need to customize the mail templates. See Customizing your Issue Navigator.
  • JRA-7266 にはこの改善に対するよう要求リクエストがあり、この実装のチャンスを改善するよう投票できます。
  • 次回 JIRA をアップグレードするとき、または何らかの理由で新しいインストールが必要となった場合は、Velocity テンプレート (および JSP) に加えた変更を手動で JIRA にコピーする必要があります。新しいバージョンで Velocity テンプレートおよび JSP に変更されている場合、カスタマイズをそれらに手動でインポートする必要があります (対照的に、これらのファイルを古い JIRA インストールからアップグレード後のバージョンに直接コピーします)。

Velocity テンプレートやその他の JIRA ファイルのカスタマイズは、アトラシアンサポートの範囲には含まれません。

メール テンプレートの場所

To customize 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 favorite text editor. Referring to the JIRA template documentation (particularly Velocity Context for Email Templates) and Velocity Users Guide, make the customizations 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.

高度なカスタマイズ

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 年 9 月 12 日

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

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