Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Scenario
"Our Jira project is a time-boxed initiative, and we'd like to trackProblem
You want to track the overall completion progress in terms of hours spent vs
estimated"We'll show you how to do all of this using Power Scripts™ for Jira - a powerful scripting tool to help automate your Jira.
What This Script Does. estimated for a time-boxed Jira project.
Solution
The solution involves the execution of the following steps:
Whenever an issue within the project is created , or edited in the project, or a worklog is generated, this the provided script runsis triggered.
It sums all the estimated hours on all issues in the project, sums all the logged work hours on all issues in the project, calculates the project percentage complete (in terms of hours), and then adds a human-readable comment to a "master tracker" issue with the latest data. e.g.
For example, "This project has *200h* estimated work with *120h* spent for a total of *80h* remaining. It is *60%* complete."
It The script is flexible and can be easily be modified adapted to populate custom fields instead of generating a comment. This modification has now been reflected in the example script.
Prerequisites
You have Jira Core, Software, or Service Desk must be installed.
You have Power Scripts™ for Jira must be installed.
You have created four custom fields of type "interval" and mapped those custom field IDs to the following aliases in the sil.aliases file:
projectTotalTimeEstimated
projectTotalWorkLogged
projectTotalTimeRemaining
projectPercentComplete
Modifications Required
Modify the script to reference a single project to calculate totals.
Modify the script to reference a single designated issue to append for appending comments to.
Configuration
Trigger this the script on the following system events:
Issue Created
Issue Edited
Work Logged on Issue
Table of Contents
Table of Contents |
---|
Script
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.
Code Block |
---|
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);
} |
Table of Contents
Table of Contents |
---|