Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

This section contains a collection of functions for handling boards, sprints, issues, and ranking, etc.

Info

Please note that some of the epic operations do not work on next-gen projects.

Child pages (Children Display)
sorttitle
excerptTypesimple

The cloud version uses the following structures:

JSprint

Code Block
int id; //sprint id
string name; //sprint name
date startDate; //start date, may be null
date endDate; // end date, may be null
date completeDate; // non-null only for completed sprints
string goal; //goal of the sprint
state state; //active, future, completed
int boardId; // the board id it belongs to

JBoard

Code Block
int id; // the id of the board
string name; //name
string type; //kanban, scrum, simple

JEpic

Code Block
int id; // id of the epic
string name; // name of the epic
string summary; // summary
boolean done; // true if this is a done epic

Example 1

The following plans a sprint directly from the backlog issues which have the Story Points field set.

Code Block
languagejava
const int MAX_SP = 10;

//get all the boards
JBoard [] boards = getAllScrumBoards("PROJECT"); //change your project key here
if(size(boards) == 0) {
    return "NOT PLANNED. No such board";
}
//there can be only one, so we select the first:
JBoard board = boards[0];

//select issues from backlog with SP set, according to their priority, not Rank
string [] backlog = issuesInBacklog(board.id, "\"Story Points\" is not null ORDER by priority");

if(size(backlog) == 0) {
    return "NOT PLANNED. No issues in backlog";
}

//create a new sprint
int sprintid = createSprint(board.id, "Auto planned sprint", "Goal is to demo this sprint feature.");

runnerLog("Created sprint");

int sum = 0;
int ndx = 0;
while(sum < MAX_SP && ndx < size(backlog)) {
    string isskey = backlog[ndx];
    addIssueToSprint(isskey, sprintid); //add that issue to the sprint
    sum += %isskey%.#{Story Points}; //maintain the sum of SPs
    runnerLog("Adding " + isskey + " into the sprint, total SP:" + sum );
    ndx++;
}
//we will go a bit overboard those 10 points per sprint but doesn't matter, we'll get the idea. Feel free to 
// improve this script, including trying to get a better fit or something. MAX_SP is not really a max.

return "PLANNED.";

Example 2

Installing the following listener on the Sprint Created event will allow you to create automatically recurrent issues:

Code Block
languagec
JSprint sprint = getSprintFromEvent();
if(sprint == null) {
    return; //avoid execution if run from SIL Manager
}
JBoard board = getBoardFromEvent();
if(board == null) {
    return; //avoid execution if run from SIL Manager
}

if(!arrayElementExists(projectsForBoard(board.id), "TEST")) {
    //we need to be on the TEST project, right ?
    return;
}
//create here the issues, as many as you want. This example creates just one.
string k = createIssue("TEST", "", "Task", "This is a recurrent task. Each sprint has one");
addIssueToSprint(k, sprint.id);