Automation For Jira: How to write a rule that will send an email including the customer facing URL of the attachments

お困りですか?

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

コミュニティに質問

robotsnoindex

プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。

このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

要約

The purpose of this KB article is to describe how to write an automation rule that will send an email to JSM (Jira Service Management) customers that will:

  • include the last comment added to a JSM request
  • convert the attachment URLs from the Jira (agent) facing URLs into the Customer facing URLS

問題

When using the smart value {{comment.body.html}} to include the last comment added to a request, if the comment contains attachments, the URLs of these attachments will be the internal Jira URLs and not the Customer facing URL. As a result, this smart value cannot be used as it is, since the customer who receives the email will not be able to open the attachment because the internal Jira URL of attachments can only be opened by Jira users with a license.

Let's assume that the attachment file name is screenshot-1.png, and that it was attached to a Jira issue which Database ID is 10100 (not to be confused with the issue key). In this case:

  • the Jira facing URL of this attachment will be:

    <JIRA_BASE_URL>/secure/attachment/10101/10101_screenshot-1.png
  • the Customer facing URL of this attachment will be

    <JIRA_BASE_URL>/secure/servicedesk/customershim/secure/attachment/10101/10101_screenshot-1.png?fromIssue=10100

The automation rule described in this article will make the conversion from the Jira facing URL into the Customer facing URL of all attachments included in the comment.

環境

  • Jira Service Management Server/Data Center on any version from 4.0.0
  • Automation for Jira バージョン 9.0.0 以降

ソリューション

Rule configuration details

The rule needs to be configured as described below:

  • Add the Issue Commented trigger
  • Add the Create Variable action with the parameters below:
    • Variable name: issueID
    • Smart value:

      {{issue.id}}
  • Add the Send Email action with the parameters below:
    • To: add the recipient of your choice
    • Subject: add the subject of your choice
    • Content: add the content below

      {{issue.comments.last.author}} added a new comment:
      
      {{issue.comments.last.body.html.replaceAll("/secure/attachment/", "/servicedesk/customershim/secure/attachment/").replaceAll("(/secure/attachment/)(\\d{5})(.*?)\"","$1$2$3?fromIssue=IssueIdToReplace\"").replaceAll("IssueIdToReplace",issueID.trim())}}

Screenshot of the rule

The complete rule is illustrated in the screenshot below:



最終更新日 2024 年 9 月 5 日

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

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