HI,
im having issues with a script of Linking issues to another in a post function.
On some it returned a positive result and mostly it returns a null pointer exception. Below is my code:
def fff = issue
def desc = issue.description
def reg = desc.find("(?i)WSM-[0-9][0-9][0-9][0-9]")
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueByKeyIgnoreCase(reg)
String ioio = issue
def issueObject = issueManager.getIssueObject(ioio)
def ComponentManager componentManager = ComponentManager.getInstance();
def issueLinkManager = ComponentAccessor.getIssueLinkManager();
def issueLinkTypeManager = componentManager.getComponentInstanceOfType(IssueLinkTypeManager.class);
def issueLT = issueLinkTypeManager.getIssueLinkType(11203);
def authContext = ComponentAccessor.getJiraAuthenticationContext()
def User = authContext.getLoggedInUser()
def linkID = issueLT.getId()
issueLinkManager.createIssueLink(issueObject.getId(), fff.getId(), (linkID), Long.valueOf(0), User)
this is the result:
There was an error during the execution of your script
java.lang.NullPointerException
com.atlassian.jira.issue.link.DefaultIssueLinkManager.getIssueLink(DefaultIssueLinkManager.java:381) com.atlassian.jira.issue.link.DefaultIssueLinkManager.createIssueLink(DefaultIssueLinkManager.java:89) com.atlassian.jira.issue.link.IssueLinkManager$createIssueLink$0.call(Unknown Source) org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) script15308646575551046973837.run(script15308646575551046973837.groovy:47) com.innovalog.groovy.GroovyExpression.testScript(GroovyExpression.java:228) com.innovalog.groovy.rest.GroovySupportRestApi.testScript(GroovySupportRestApi.java:212) sun.reflect.GeneratedMethodAccessor6022.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498)
thank you
Hello Nkosi,
in cases like this I would recommend you take a look into Jira source files. It is important to check the exact version of source files matching your running instance. I tried to check your problem on my 7.5.2 sources and it looks like there are some existing invalid links that don't have destination or linkType specified.
When I look at your script, I see that you are trying to create links from an issue to itself. Is it good? Couldn't this cause some inconsistencies in data that result in NullPointerException?
Regards,
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.