How to set Original Estimate based on a value from Timepiece ?
Business Need
Let's presume ...
You are using Jira for task management.
Issues are created in Open status, moved to InProgress while working on them, and moved to Resolved when the work is completed.
To automate estimation, you want to set the Original Estimate of a newly created issue to the average InProgress time of the issues resolved in the last 30 days.
Solution
You can automate setting the Original Estimate by creating a Jira Automation rule that runs when a new issue is created, requests a Timepiece report via the REST API of Timepiece, and sets the Original Estimate value based on the result of that report.
You should...
- Create a new Jira Automation Rule
- Add "Issue Created" as the trigger
- Add action "Send Web Request"
- Set the "Web Request URL" to
- https://tis.obss.io/rest/aggregation?filterType=customJQL&customjql=project={{issue.project.key}}%20and%20issuetype%20%3D%20Story&columnsBy=statusDuration&aggregationType=average&calendar=normalHours&dayLength=24HourDays&startDate={{now.minusDays(30).format("yyyy-MM-dd")}}&dateRangeField=resolved&statuses=3&viewFormat=minutes
- This is a sample request URL that will return the average InProgress time of issues resolved in the last 30 days. You can modify the parameters in this URL according to your needs.
- For complete details about REST API parameters, see Timepiece REST API Documentation for /aggregation endpoint.
- For reference on using smart values, see the Atlassian documentation here.
- Add Header
- Authorization
- TISJWT <your_tisjwt>
- Replace <your_tisjwt> with the JWT API key you created through the API Settings page.
- Set HTTP Method
- POST
- Web Request Body
- Empty
- Make sure you check "Delay execution of subsequent rule actions until we've received a response for this web request"
- The configured action should look like this
- Set the "Web Request URL" to
- Add action "Create Variable"
- Set Variable Name
- averageInProgressInMinutes
- Set Smart Value
- {{webResponse.body.table.body.rows.valueColumns.value.get(0)}}
- The configured action should look like this
- Set Variable Name
- Add Action "Edit Issue"
- Select the Original Estimate field.
- Set Original Estimate Smart Value
- {{averageInProgressInMinutes.asNumber.format(".#")}}m
- The configured action should look like this
- Enter a name for your new rule and turn it on
Notes
To efficiently modify this case according to your needs, you will need to have knowledge about Jira Automation configuration and HTTP REST APIs in general.
It will be hard to build the complete REST URL directly through the Jira Automation interface. It is recommended that you first try and build the report parameters somewhere else first (cURL or Postman will do) and then use it in automation.
Make sure your report URL doesn't call a TiS report that uses too many issues. Depending on the frequency of your triggers, this might put too much pressure on your Jira and the rules will take longer to complete. Getting reports for up to a few hundred issues should be no problem. The performance impact might be significant as you approach higher issue counts. Keep an eye on your automation rule execution durations under Audit Logs.
The /aggregation REST API endpoint is limited to 60 seconds. It will return errors for requests that take more than 60 seconds to process. Processing time is mostly dependent on the number of issues included in the report.