Set the epic link of an issue created with ScriptRunner clone an issue and links

Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2017

Hi,

I am trying to set the Epic link of an issue that is created with the clone an issue and link script from ScriptRunner.

I have the following script in a post-function in the additional actions field:

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor

issue.summary = '[SR] ' + sourceIssue.summary

def issueManager = ComponentAccessor.getIssueManager()

def epicIssue = issueManager.getIssueObject('AQ-12249') // Support requests epic
def epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link')
issue.setCustomFieldValue(epicLink, epicIssue)

UserMessageUtil.success("Created issue for development.")

When I run this, I get the following Nullpointer:

Caused by: java.lang.NullPointerException
at com.atlassian.jira.issue.link.DefaultIssueLinkManager.getIssueLink(DefaultIssueLinkManager.java:373)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy211.createIssueLink(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy211.createIssueLink(Unknown Source)
at com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl.createLink(EpicLinkManagerImpl.java:322)
at com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl.updateLinksForIssues(EpicLinkManagerImpl.java:238)
at com.atlassian.greenhopper.manager.issuelink.EpicLinkManagerImpl.associateIssuesWithEpic(EpicLinkManagerImpl.java:179)
at com.atlassian.greenhopper.service.issuelink.EpicServiceImpl.addIssuesToEpic(EpicServiceImpl.java:103)
at com.atlassian.greenhopper.customfield.epiclink.EpicLinkCFType.associateIssueWithEpic(EpicLinkCFType.java:686)
at com.atlassian.greenhopper.customfield.epiclink.EpicLinkCFType.createValue(EpicLinkCFType.java:202)
at com.atlassian.greenhopper.customfield.epiclink.EpicLinkCFType.createValue(EpicLinkCFType.java:44)
at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(ImmutableCustomField.java:693)
at com.atlassian.jira.workflow.function.issue.IssueCreateFunction.execute(IssueCreateFunction.java:81)
at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1014)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1407)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:606)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)

Any ideas what I am doing wrong here?

 

Thanks,

Geert 

1 answer

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2017

Hi Geert,

You additional script looks fine. So I suppose the issue may is with the clone issue post function configuration. Do you mind to share that configuration ? For example which fields you selected to be copied, etc. 

Also for which step you have set up the post function and in what order ?

Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2017

Hello Thanos,

 

Thank you for your reply. Below are screenshots from the clone-and-link configuration and the workflow in which this function is called.

Please note that I disabled the additional issue actions which caused problems, so you do not see them here.

Thanks,

Geert

clone-config.pngworkflow.png

Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2017

Ok, something else I just noticed: we cannot set this specific epic link for any issue, and when I navigate to the (epic) issue, it shows an error as described here: https://confluence.atlassian.com/jirakb/issue-screen-displays-error-rendering-greenhopper-epics-issue-web-panel-779158857.html.

So I think the epic issue is somehow corrupted.

Suggest an answer

Log in or Sign up to answer