Track completion progress

Problem

You want to track the overall completion progress in terms of hours spent vs. estimated for a time-boxed Jira project.

Solution

The solution involves the execution of the following steps:

  • Whenever an issue is created or edited in the project, or a worklog is generated, the provided script is triggered.

  • It sums all estimated hours on all issues in the project, sums all logged work hours on all issues in the project, calculates the project percentage complete (in terms of hours), and then adds a comment to a "master tracker" issue with the latest data. 

    • For example, "This project has *200h* estimated work with *120h* spent for a total of *80h* remaining. It is *60%* complete."

  • The script is flexible and can be easily adapted to populate custom fields instead of generating a comment. This modification has been reflected in the example script.

Prerequisites

  1. Jira Core, Software, or Service Desk must be installed.

  2. Power Scripts™ for Jira must be installed.

  3. You have created four custom fields of type "interval" and mapped those custom field IDs to the following aliases in the sil.aliases file:

    1. projectTotalTimeEstimated

    2. projectTotalWorkLogged

    3. projectTotalTimeRemaining

    4. projectPercentComplete

Modifications Required

  1. Modify the script to reference a single project to calculate totals.

  2. Modify the script to reference a designated issue for appending comments.

Configuration

Trigger the script on the following system events:

  • Issue Created

  • Issue Edited

  • Work Logged on Issue

Script

This script runs whenever an issue is created, updated, or work is logged on an issue in the applicable project.

It adds a comment to a specific issue to explain how many total hours are estimated and logged in the project, and gives a percentage complete value. The script can be tailored to populate fields instead of adding a comment as needed.

string projectInScope="SMSW"; // the project you want to sum up string masterIssue="SMSW-23"; // issue where you want to capture this info if(project==projectInScope) { // if invoked via listener, limit the scope string jql="project="+projectInScope; string [] allProjectIssues=selectIssues(jql); string issue; string commentText; interval sumOriginalEstimate; interval sumTimeSpent; interval sumTimeRemaining; number hoursOriginalEstimate; number hoursTimeSpent; number completePercent; number countIssues=0; for(issue in allProjectIssues) { sumOriginalEstimate += %issue%.originalEstimate; sumTimeSpent += %issue%.timeSpent; countIssues +=1; } sumTimeRemaining = sumOriginalEstimate - sumTimeSpent; hoursTimeSpent = sumTimeSpent; hoursOriginalEstimate = sumOriginalEstimate; completePercent = round((hoursTimeSpent/hoursOriginalEstimate)*100,0); %masterIssue%.projectTotalTimeEstimated = sumOriginalEstimate; %masterIssue%.projectTotalWorkLogged = sumTimeSpent; %masterIssue%.projectTotalTimeRemaining = sumTimeRemaining; %masterIssue%.projectPercentComplete = completePercent; string commentTextA = "This project has *"+sumOriginalEstimate+"* estimated work"; string commentTextB = " with *"+sumTimeSpent+"* spent for a total of *"; string commentTextC = ""+sumTimeRemaining+"* remaining. "; string commentTextD = "It is *"+completePercent+"%* complete. "; string commentTextE = "This update brought to you changes made in "+key+"."; commentText = commentTextA + commentTextB + commentTextC + commentTextD + commentTextE; addComment(masterIssue, currentUser(), commentText); }