Moving unclosed issues from last closed sprint on next sprint and updating story points for Jira Agile

Moving unclosed issues from last closed sprint on next sprint and updating story points for Jira Agile

Requires apps

  1. Jira Agile
  2. Power Scripts™ for Jira (server)

Level: BASIC


Problem

We need to run an administration script to move unclosed issues from last closed sprint on current started sprint, if any, or on next sprint, updating the story points with the remaining estimated.

Solution

Creating a SIL script file

  1. Log in as a Jira administrator and navigate to Administration > Add-ons > cPrime Tools > SIL Manager. Select silprograms in the left panel of SIL™ Programs Manager, click the New button.



  2. Select New file option and type your new script file name. Remember to add the .sil extension. Save the name by checking the input box,  put this SIL™ code into the right panel.



    NewTestFil.sil
    string message="";
    string brd=getElement(argv, 0);
    number lastClosedSprint=0;
    number nextSprintInSprints=-1;
    string unclosedIssues="";
    string[] closedIssuesInClosedSprint;
    if (isNull(brd))
    {
     message = "Missing parameter: Board name.";
     return message;
    }
    lastClosedSprint=getElement(closedSprints(brd),size(closedSprints(brd))-1);
    if (size(notStartedSprints(brd))>0)
    {
     nextSprintInSprints=getElement(notStartedSprints(brd), 0);
    }
    closedIssuesInClosedSprint=selectIssues("sprint = " + lastClosedSprint + " AND status = 'Closed'");
    for (string iss in closedIssuesInClosedSprint)
    {
     removeIssueFromSprint(iss, lastClosedSprint);
     if (isNotNull(startedSprints(brd)))
     {
     addIssueToSprint(iss, getElement(startedSprints(brd),0));
     }
     else
     {
     if (nextSprintInSprints>-1)
     {
     addIssueToSprint(iss, nextSprintInSprints);
     }
     }
     
     if (isNotNull(%iss%.originalEstimate) and originalEstimate!=0 and isNotNull(%iss%.estimate))
     {
     interval originalInterval=%iss%.originalEstimate;
     interval remainingInterval=%iss%.estimate;
     number points =#{%iss%.Story Points};
     number originalMillies = originalInterval["TOMILLIS"];
     number remainingMillis = remainingInterval["TOMILLIS"];
     number newPoints=round(points * remainingMillis / originalMillies, 0);
     #{%iss%.Story Points}=newPoints;
     }
     unclosedIssues = unclosedIssues + ", " + iss;
    }
    if (startsWith(unclosedIssues, ", ") )
    {
     unclosedIssues=substring(unclosedIssues, 2, -1);
    }
    message = "Unclosed issues " + unclosedIssues + " were removed from Sprint " + lastClosedSprint + " and added to Sprint " + nextSprintInSprints + ".";
    message = message + "Story points have been updated.";
    return message;
  3. Click Check  to validate the syntax and Save your file.


Configuring and Running the SIL™ Runner Gadget

  1. Add the Power Scripts™ for Jira gadget on your dashboard.



  2.  Edit it from the up-right corner arrow. Add the new script that should be run. Configuring it.



  3. Click Save the configuration. 

  4. That's it. Now you can run this script as a Jira administrator. All you need is to add the board name as a parameter and to click the Run! button.


    Hope you'll enjoy!

See also