Extracting the Last Five Comments from Jira Issues Using Automations

お困りですか?

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

コミュニティに質問

robotsnoindex

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

要約

This article provides a detailed guide on how to use Jira Automation to extract the last X comments from an issue in Jira. This is particularly useful for project managers and team leads who need to stay updated on issue progress and team discussions.

環境

Jira Cloud

診断

To diagnose if this is the solution you need, ask the following questions:
- Do you frequently need to stay updated on the most recent discussions on a Jira issue?
- Do you find it time-consuming to manually find and read through the latest comments?
- Are you looking for a way to automate this process and receive the latest comments directly in your email?

原因

Jira users often need to extract a certain number of recent comments from a list of issues, but there is no direct way to limit or filter a list using Jira smart values. You can access the first or last comment, or use .get() and .getFromEnd() to access a specific comment in the list, but extracting a specific number of comments requires a different approach.


ソリューション

To solve this issue, we will use Jira Automation. This involves creating a variable to store the comments in a text string and then using a regular expression to select the first five items. Here's how you can do it:

Step 1: Create a variable to store the consolidated list and their 0-based index
- Name: varLookupData
- Smart value: Create a text string, delimited by ";index:" at the beginning of each issue.

{{#issue.comments.reverse}};index:{{index}} - {{author.displayName}} {{created.convertToTimeZone("Asia/Kolkata").format("dd-MM-yy hh:mm a")}} {{body}} {{/}}


Step 2: Log the results (or whatever you need) with the results of the first 5 items

{{varLookupData.split(";index").match(":((0|[1-5]) .*)").substringAfter(" - ")}}


This will split the text string on ";index" and create a new list. The match() function will then find only items beginning with ":0" through ":19". The final substringAfter removes the index prefix information, leaving only the summary and author.

However, this will output the final list as a string, and may not parse for HTML. To build your HTML, you can use the `list.getFromEnd(index)` function. Here's an example:

<tr bgcolor="#ffffff">
    <td>{{issue.comments.reverse.getFromEnd(0).author.displayName}}</td>
    <td>{{issue.comments.reverse.getFromEnd(0).created.convertToTimeZone("Asia/Kolkata").format("dd-MM-yy hh:mm a")}}</td>
    <td>{{issue.comments.reverse.getFromEnd(0).body}}</td>
</tr>


By following these steps, you can automate the process of extracting the last five comments from a list of Jira issues and send them via email, saving you valuable time and ensuring you stay updated on the latest issue progress and team discussions.

For more details on Jira Smart Values, please refer to the official Jira documentation: https://support.atlassian.com/ja/jira-software-cloud/docs/smart-values-general/.

Remember, automation can save you time and reduce manual errors. Start using Jira Automation today and streamline your project management process.



最終更新日 2024 年 6 月 10 日

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

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