Hello,
I'm looking for a groovy script that can give average cycle time of a story in an epic.
for instance, if an epic has a story and it closed in 2 hrs, the average cycle time will be 2 hrs.
if an epic has two stories and one closed in 1 hr and another one closed in 3 hrs, the average cycle time will be different.
any help would be appreciated.
Note: we already have two scripted fields one gives the total cycle time of an issue and another one gives the number of issues in an epic.
You should simply merge the two existing scripts into a third:
return (output of number of issues script / output of total cycle change script)
Note that the other option people may think of here is to calculate the third field from the first and second - do not do that, as fields are not always calculated in the order you think they are, so you could end up with the wrong answer.
import com.atlassian.jira.ComponentManager is not working ! is there any alternative package for this. since it is deprecated.
Version is V8.5
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- could you help me to merge these two scripts please.
number of stories:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor;
def componentManager = ComponentManager.getInstance()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def cfManager = ComponentAccessor.getCustomFieldManager()
double completedSP = 0
enableCache = {-> false}
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link") {
completedSP= 1 + completedSP;
}
}
completedSP=completedSP.trunc()
return completedSP
Time spent:
import com.atlassian.core.util.DateUtils
def resolvedNames = ["Resolved", "Closed"]
def timeDiff;
if (issue.getStatus().name in resolvedNames) {
timeDiff = issue.getResolutionDate().getTime() - issue.getCreated().getTime()
} else {
timeDiff = System.currentTimeMillis() - issue.getCreated().getTime()
}
return (double) timeDiff/(1000*60*60)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rearrange the imports up to the top. Remove the line "return completedSP", and change the last line so it divides by completedSP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried like this:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.core.util.DateUtils
def componentAccessor = ComponentManager.getInstance()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def cfManager = ComponentAccessor.getCustomFieldManager()
double completedSP = 0
enableCache = {-> false}
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link") {
completedSP= 1 + completedSP;
}
}
completedSP=completedSP.trunc()
def resolvedNames = ["Resolved", "Closed"]
def timeDiff;
if (issue.getStatus().name in resolvedNames) {
timeDiff = issue.getResolutionDate().getTime() - issue.getCreated().getTime()
} else {
timeDiff = System.currentTimeMillis() - issue.getCreated().getTime()
}
return (double) timeDiff/(1000*60*60)
And i'm getting this error
$jiraDurationUtils.getFormattedDuration($value, $jiraAuthenticationContext.getLocale())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're using the wrong template for the output of the field. Return (double) should probably be going out through a numeric field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.