Hi,
Using Script runner I'd like to read all the 'Linked Epic Issues' from the epic object and create a script Field to be used on my card layout. Basically I want to display an epic with all the Linked Epic Issues on my board.
Reading normal links is pretty simple:
JiraAuthenticationContext authContext = ComponentManager.getInstance().getJiraAuthenticationContext(); IssueLinkManager issueLinkManager = ComponentManager.getInstance().getIssueLinkManager(); LinkCollection linkCollection = issueLinkManager.getLinkCollection(issue, authContext.getLoggedInUser()); Set<IssueLinkType> linkTypes = linkCollection.getLinkTypes(); return linkCollection.getAllIssues().toString()
But how to read the Linked Epic Issues
CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField cf = cfManager.getCustomFieldObjectByName('Linked Epic Issues'); return cf.getGenericValue().toString()
returns
[GenericEntity:CustomField][id,10201][project,null][fieldtype,null][default,null][issuetype,null][customfieldsearcherkey,com.onresolve.jira.groovy.groovyrunner:textsearcher][description,null][name,Linked Epic Issues][customfieldtypekey,com.onresolve.jira.groovy.groovyrunner:scripted-field]
I can see that there is API EpicLinkManagerImpl
And even some examples
https://gist.github.com/ark09/c62a20c4cdae3f98df85
But
def epicLinkManagerImpl = getBean("epicLinkManagerImpl");
Returns
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getBean() is applicable for argument types: (java.lang.String) values: [epicLinkManagerImpl]
Possible solutions: getAt(java.lang.String), get(java.lang.String), getClass(), eval(java.lang.String)
A stacktrace has been logged
And when I try to import the EpicLinkManagerImpl I'm getting
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script65.groovy: 19: unable to resolve class com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl
@ line 19, column 1.
import com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl
So the package is not visible from the Script Runner at all.
So How do I access the instance of the EpicLinkManagerImpl then?
Hi,
Strongly inspired by https://answers.atlassian.com/questions/263840 I got a list of issues with this script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.fugue.Option if(issue.issueType.name=="Epic") { def epic = (Option)Option.option(issue) def epicLinkManagerImpl = getBean("epicLinkManagerImpl"); issuesInEpic = epicLinkManagerImpl.getIssuesInEpic(issue) return issuesInEpic.toString() } return null //Method to get the greenhopper bean instance def getBean(String beanId) { def ghPlugin = ComponentAccessor.getPluginAccessor().getEnabledPlugin("com.pyxis.greenhopper.jira") def descriptor = ghPlugin.getModuleDescriptor("greenhopper-launcher") def applicationContext = descriptor.getModule().greenHopperCacheManager.applicationContext def beanInstance = applicationContext.getBean(beanId) return beanInstance; }
Wow! I've been looking for a way to retrieve "Issues in Epic" for a long time - thanks Knud!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A pity Atlassian does not simply export EpicLinkManager service from OSGi plugin with @ExportAsService
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.
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.