Forums

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

How do I modify sprint end date for a closed sprint?

Carsten Schäfer
Contributor
April 11, 2019

We forgot to end a sprint on the correct date.

The problem is that the end is always set to the date when the sprint is closed.

How can i set the end/close date for a past/closed sprint? (these are not shown in the backlog)

I know that i can reopen a sprint but when i close it again it will always take the current date and i cannot set it to the correc date.

2 answers

1 accepted

1 vote
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 7, 2018

Hello,

How do you initialize the issues variable? It is an ArrayList. I guess it is an ArrayList<Issue>. But to make sure I need to see your code.

If it is ArrayList<Issue> it would work like this:

def estField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total Remaining Estimate") 
def cFieldValue
issues.each{
cFieldValue = (double) it.getCustomFieldValue(estField)
}
Tyler Brown-Jones
June 7, 2018

Thanks for the reply, this is my full code:

 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import java.util.logging.Logger
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter


def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug("start of code")

jqlSearch = 'updated >= -4w'; // Create the JQL query to perform

SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
UserUtil userUtil = ComponentAccessor.getUserUtil();
def user = ComponentAccessor.getUserManager().getUserByName("jira_bot")


// Set the default list of issues to null just to be safe
List<Issue> issues = null;

// Perform the search as a user and return the result so it can be validated.
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);



if(parseResult.isValid()){
log.debug("inside parse if")
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
issues = searchResult.issues
log.debug(issues)
issues.each(){
log.debug("inside loop")
def estField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total Remaining Estimate")
def cFieldValue = (double) issues.getCustomFieldValue(estField)
log.debug(cFieldValue)
if ( cFieldValue == 0.0) {
def subject = "${issues.key} has no Estimate"
def body = "https://test.atlassian.net/issue/${issues.key} \n This issue does not have an estimate"
def emailAddr = "bot@test.com"
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()

if (mailServer) {
Email email = new Email(emailAddr);
email.setSubject(subject);
email.setBody(body.toString());
mailServer.send(email);
log.debug("Mail sent")
}
else {
log.debug("Please make sure that a valid mailServer is configured")
}
}
}
}
else{
log.error("Invalid JQL: " + jqlSearch);
}


 

 Hope you are able to identify the issue a bit better now, Thanks @Alexey Matveev

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 7, 2018

Thank you for the code. It should be like this:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import java.util.logging.Logger
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter


def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug("start of code")

jqlSearch = 'updated >= -4w'; // Create the JQL query to perform

SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
UserUtil userUtil = ComponentAccessor.getUserUtil();
def user = ComponentAccessor.getUserManager().getUserByName("jira_bot")


// Set the default list of issues to null just to be safe
List<Issue> issues = null;

// Perform the search as a user and return the result so it can be validated.
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);



if(parseResult.isValid()){
log.debug("inside parse if")
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
issues = searchResult.issues
log.debug(issues)
issues.each(){ issue ->
log.debug("inside loop")
def estField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total Remaining Estimate")
def cFieldValue = (double) issue.getCustomFieldValue(estField)
log.debug(cFieldValue)
if ( cFieldValue == 0.0) {
def subject = "${issue.key} has no Estimate"
def body = "https://test.atlassian.net/issue/${issue.key} \n This issue does not have an estimate"
def emailAddr = "bot@test.com"
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()

if (mailServer) {
Email email = new Email(emailAddr);
email.setSubject(subject);
email.setBody(body.toString());
mailServer.send(email);
log.debug("Mail sent")
}
else {
log.debug("Please make sure that a valid mailServer is configured")
}
}
}
}
else{
log.error("Invalid JQL: " + jqlSearch);
}
Tyler Brown-Jones
June 7, 2018

You're great, thanks for this it has got it working.

 

Could you explain what issue -> does within the loop please? just so i know for future reference.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 7, 2018

When you do a loop with the each statement you can reference each element of an array with the it variable. But I tend to rename this variable so, that it would be more understandable. That is why issue -> means that you will be using the issue variable instead of the it variable. If you remove the issue -> part, then you can change all issue. parts with the it. part.

Like Quinton Lephoto likes this
Tyler Brown-Jones
June 7, 2018

Ahh, thanks for the great explanation. I will use this more in the future, thank you again @Alexey Matveev you have been a valid source of help and information these past days.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 7, 2018

@Tyler Brown-Jones you are welcome!

0 votes
Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 7, 2018

HI @Tyler Brown-Jones

Try to use like this and check

import com.atlassian.jira.issue.fields.CustomField;

 

CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(new Long(10266));

Issues.getCustomFieldValue(cf)

Tyler Brown-Jones
June 7, 2018

that's exactly what i did apart i referenced by name as it works fine for immutableCustomFields , but why the (new Long(10266)) part in your code?

Suggest an answer

Log in or Sign up to answer