The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get the sprints which are having only closed issues based on the sprint start date

Bhargavi Vasa
Contributor
March 20, 2023

Able to fetch the sprint details which are having only closed issues for the given date(sprint details and issues under it) but getting other sprint details as well with no issues for the below code

Can someone help me to modify this code to skip the unwanted sprints which do not have the issues and print only the sprints based on the conditions

 

string format = "MM/dd/yyyy"; //format for date
string creationdate = currentDate()-"90d";
runnerLog("creation date: " + creationdate);
for(JSprint sprint in getAllOpenSprints()) {
if (sprint.startDate < creationdate && sprint.state =="ACTIVE") {

string [] keys =selectIssues("Sprint = '" +sprint.name+ "'");

Boolean allClosed =true;

for(string key in keys) {

if(key.status!="Closed"){

all closed=false;

break;

}

}

if(allClosed){

runnerLog("Sprint name: " + sprint.name);
runnerLog("Sprint id: " + sprint.id);
runnerLog("Sprint start date: " +formatDate(sprint.startDate, format));
runnerLog("Sprint state: " +sprint.state);
runnerLog(keys);

updateSprint(sprint.id, sprint.name, "Closed" );
runnerLog("Sprint was updated: " + sprint.name );
}
}

}

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Bhargavi Vasa
Contributor
March 21, 2023

string format = "MM/dd/yyyy"; //format for date

string creationdate = currentDate()-"90d";

runnerLog("creation date: " + creationdate);

for(JSprint sprint in getAllOpenSprints()) {

if (sprint.startDate < creationdate && sprint.state =="ACTIVE") {

string [] keys =selectIssues("Sprint = '" +sprint.name+ "'");

if(length(key)==0){

continue;

}

Boolean allClosed =true;

for(string key in keys) {

if(key.status!="Closed"){

all closed=false;

break;

}

}

if(allClosed){

runnerLog("Sprint name: " + sprint.name);

runnerLog("Sprint id: " + sprint.id);

runnerLog("Sprint start date: " +formatDate(sprint.startDate, format));

runnerLog("Sprint state: " +sprint.state);

runnerLog(keys);

updateSprint(sprint.id, sprint.name, "Closed" );

runnerLog("Sprint was updated: " + sprint.name );

}

}

}