Hello,
We have a high level issue type called "Capability". That is the 'Parent of', via regular issue links the standard JIRA Epic issue type.
Inside epics, as issues in epics, we have stories and actions issue types. Stories and/or actions might have sub-tasks, or not (called 'Task').
When we transition a Capability to a certain status, we would like to add a comment to it that will write:
Number of Epics with a certain link in a URL field (http:\\test)
Number of stories
Number of actions
Number of tasks (the tasks have a field called TaskType - select list) . It would be great to count per task type.
Would it be possible to achieve this via a Scriptrunner postfunction?
Any code is appreciated.
Thank you!
Hi,
Yes, that is easy to do.
I'll give you some examples (counting stories/tasks in Epics and counting subtasks in issues). I guess you can extend this to your requirements ? (your link names, issue type names, ... add tests on custom field, ...)
Count Stories/tasks in Epics (assume you have an Epic in variable epicIssue) :
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
Integer count = 0
issueLinkManager.getOutwardLinks(epicIssue.getId()).each {epicLink ->
if (epicLink.getIssueLinkType().getName() == "Epic-Story Link") {
Issue epicLinkedIssue = epicLink.getDestinationObject()
String liIssueType = epicLinkedIssue.getIssueType().getName()
if (liIssueType in ["Story", "Task"] {
count ++
}
}
}
Count subtasks in issue:
Integer count = 0
issue.getSubTaskObjects().each { subIssue ->
String issueType = subIssue.getIssueType().getName()
if (issueType == "Sub-task") {
count ++
}
}
Hi @Mihai Mihai ,
My script validator check if story has link to issue type 'test' and project 'PRKEY'.
if (issue.issueType?.name == 'Story'){
def hasT = false
def links = issueLinkManager.getOutwardLinks(issue.getId())
if (links.find{ (it.getDestinationObject().issueType?.name == 'TestCase') && (it.getDestinationObject().getProjectObject().getKey() == 'PRKEY') }){
hasT = true
}
if (hasT){
return true
}else{
return false
}
}
B.R.
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.