Timepiece - Time in Status for Jira

How to Auto-Comment Cycle Time on Resolved Issues via Jira Automation?

Business Need

You need an automated process that calculates an issue’s cycle time and posts it as a comment when the issue transitions to the "Resolved" status.

Solution

“DURATION BETWEEN STATUSES” report type of Timepiece, combined with Jira Automation, can be used for this purpose.

Step 1: Configure and Save the Timepiece Report

First, create a Timepiece report...

  • Open the Timepiece reporting page.

  • Select the project in which the support issues reside (Let’s presume you have selected the ABC project).

    • Any filter selection at this point works. The selection made at this stage is not critical, as it will be overridden later during the automation configuration.

  • Switch to the “DURATION BETWEEN STATUSES” report type.

  • (Optional) Select your business calendar if you have one.

  • Create a metric where the start is "First transition to In Progress", and the end is "Last transition to Resolved".

A Duration Between Statuses Report Metrics configuration Panel
  • Name this metric as "CycleTimeMetric".

  • Go to settings and save it via "Save report parameters".

    • The parameter set name should be like "ABC Project Cycle Time".

    • Make sure you select the "Share with everyone" option so others can use the param set as well.

A Timepiece Duration Between Statuses report view displaying a list of issues for the ABC Project

Step 2: Create a Jira Automation & Set General Flow Details

Navigate to Jira Automation and start a new rule.
Before configuring the automation logic, you must define the administrative settings in the Flow Details section.

Step 3: Define Trigger and Conditions

Use the “Work item transitioned” trigger and set it to fire when a work item moves to the "Resolved" status. Since our goal is to write the cycle time on an issue when the work is completed, we initiate the automation at this specific transition.

 An ABC Project Cycle Time Automation interface configuring a Work item transitioned trigger step

Step 4: Add Action - Timepiece: Run Report

After defining the trigger and conditions, add a “Timepiece: Run Report” action that will fetch the required data from Timepiece.

An ABC Project Cycle Time Automation interface showing an Add a step configuration menu offering Action Condition
In Progress to Resolved Automation-Add Timepiece.png
  • Select the report (Parameter Set) you created for this automation in the Report Settings field. Ensure that the report has been previously saved using the “Save Report Parameters” option.

An Add an action window within an automation builder displaying the Timepiece Run Report action under the other apps section

Parameter Overrides

Override some report parameters with a custom JSON. We’ll override the report filter so it returns data only for the issue that triggered the automation, which is defined by ({{issue.key}}). It ensures the automation fetches the unique cycle time for that exact issue rather than a general dataset.

Parameter Overrides: { "filterType": "customjql", "customJql": "key = {{issue.key}}" }

Step 5: Add Log Action (Optional)

Add a Log Action to your flow. This step is necessary if you want to monitor the automation and is helpful for debugging in the event of an error.
This action writes the entire dataset returned from the report as a log output, allowing you to see all available data at once.

Log Message: resultList: {{fetchedTimepieceResultList}}

An ABC Project Cycle Time Automation interface configuring a Log action step to add the fetchedTimepieceResultList value directly to the audit log

Note: For more details about the logging and debugging, see the documentation.

Step 6: Create Variable

In this step, we extract the 'CycleTimeMetric' duration from the dataset and assign it to the CycleTimeMetric variable so we can use it in later actions. This converts the detailed report output into a simple, portable format, making it easy to reference and display this specific duration in the final comment on the work item.

Variable Name: CycleTimeMetric

Smart Value: {{fetchedTimepieceResultList.first().get("CycleTimeMetric")}}

An ABC Project Cycle Time Automation interface configuring a Create variable action to store a specific metric calculation as CycleTimeMetric

Step 7: Add Log Action (Optional)

In this step, we log the value of the {{CycleTimeMetric}} variable to the audit log. This acts as a checkpoint to verify that the duration has been correctly captured from the report, ensuring the automation has the accurate data required before proceeding to the final comment step.

Log Message: {{CycleTimeMetric}}

An ABC Project Cycle Time Automation interface configuring a second Log action step to record the calculated CycleTimeMetric variable value in the audit log

Step 8: Add Comment To Work Item

In the Comment on work item step, we post the final results directly to the issue as a comment. Using the data retrieved from the Timepiece app, this comment explicitly states the exact cycle time the issue spent from 'In Progress' to 'Resolved', providing immediate visibility into the completion duration for that specific task.

Add a comment for this automation:

Hello, the cycle time for this issue has been calculated as {{CycleTimeMetric}}

An ABC Project Cycle Time Automation interface configuring a Comment on work item action to publish a message containing the calculated CycleTimeMetric variable value

Step 9: Enable the Rule

Click the "Turn on rule" button to activate the automation.

Once active, your automation will automatically post the calculated duration as a comment on issues that transition to 'Resolved', providing visibility into how long it took for each ticket to be completed.

A Jira work item view showing an automated comment in the activity section displaying the calculated cycle time value