Hi,
I am working on writing a groovy script for calculating Epic Rollups. I would like to know is there any way of getting the global values for the user, issue assuming there is an epic?
I want to use something like this,
USER = 'invinci' children = retrieveIssuesInEpic(issue) total = sumOfOriginalEstimates(children)
Here,
1. USER is the one with browse projects permissions
2. children represents the subtasks
3. sumOfOriginalEstimates(children) is the time taken.
How would I let the script know of the parent/child key values whenever an issue is created on the jira web application?
Thank you!
You don't invoke Script Fields. They are invoked when the issue is viewed. I use them heavily depending on the use-case.
Word to the wise: You should configure the custom field scope tightly for script fields. A script field can be a lot more expensive than say, a string text field. You should make sure the custom field context to only include projects and issue types that it's relevant for.
For example, this field would only be used by Software Development teams. You would only use this field on the Epic issue type. Your context should look something like this:
In addition to the custom field context, you should edit the custom field and change the searcher to Duration Searcher:
Your script should accomplish the following:
An example of what this script could look like is below. I'm no groovy expert. I do not know what version of JIRA you're using and I do not know how you want your data presented, so this may not work for you. This doesn't consider sub-tasks, so you'll likely want to obtain the aggregate estimate instead. I didn't have the time to complete this though: I just mostly took an existing field I had and modified it.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink import com.atlassian.jira.issue.link.IssueLinkManager import com.atlassian.jira.issue.link.IssueLinkType import com.atlassian.jira.issue.link.IssueLinkTypeManager import com.atlassian.jira.issue.issuetype.IssueType import com.atlassian.jira.config.IssueTypeManager enableCache = {-> false} IssueType getIssueTypeByName(String name){ for(IssueType issueType in ComponentAccessor.getComponent(IssueTypeManager.class).getIssueTypes()){ if(issueType.getName() == name){ return issueType } } return null } String issueTypeName = "Epic" String issueLinkTypeName = "Epic-Story Link" IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager() IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager.class) IssueLinkType[] issueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(issueLinkTypeName) IssueLink[] issueLinks = issueLinkManager.getOutwardLinks(issue.id) IssueType issueType = getIssueTypeByName(issueTypeName) if( issue && issueType && issueLinkTypes.size() > 0 && issue.getIssueType().name == issueType.getName() && issueLinks.size() > 0 ) { List<IssueLink> relevantIssueLinks = new ArrayList() for(issueLink in issueLinks){ if(issueLink.getIssueLinkType().name == issueLinkTypes.first().getName()){ relevantIssueLinks.add(issueLink) } } if(relevantIssueLinks.size() > 0){ Long originalEstimate = 0 for(issueLink in relevantIssueLinks){ Issue linkedIssue = issueLink.getDestinationObject() if(linkedIssue.getOriginalEstimate()){ originalEstimate = originalEstimate + linkedIssue.getOriginalEstimate() } }
if(originalEstimate > 0){ return originalEstimate
} } }
It's unclear to me: Is this a listener? You want this to execute on Issue_Created/Issue_Updated?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.