Skip to end of banner
Go to start of banner

Jira Software Functions

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Current »

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

The cloud version uses the following structures:

JSprint

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

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

JEpic

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.

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:

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);

  • No labels