I am attempting to to clone an issue as part of a workflow post-function using Scriptrunner (v4.3.16) on Jira Software (v7.1.1), running against MS SQL Server 2008. I have hit a problem with database connections going crazy, bringing down Jira. This looks to be the issue reported in https://jira.atlassian.com/browse/JRASERVER-60928.
At some point while developing the script, it worked fine. Then I added more logic to set particular custom field values on the new issue, and it broke. I'm not exactly sure when it broke though.
While I investigate the database level workaround described on JAC, can anyone advise on any particular functions I should avoid in my script to get round the problem?
This is my code from additional issue actions:
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.label.LabelManager
//Don't clone links
checkLink = {link -> false};
//Don't clone attachments
checkAttachment = {attachment -> false};
//Get the XXX field and put XXX1 in it. XXX is a multi-select field
//I'm fairly sure this part worked fine
def xxx = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'XXX'};
def xxxfieldconfig = xxx.getRelevantConfig(issue)
def xxxoption = ComponentAccessor.optionsManager.getOptions(xxxfieldconfig)?.find { it.toString() == 'XXX1' }
issue.setCustomFieldValue(xxx, [xxxoption]);
//Get the YYY field and put "YYY1" in it - YYY is a select (single) field
def yyy = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'YYY'};
def yyyfieldconfig = yyy.getRelevantConfig(issue)
def yyyoption = ComponentAccessor.optionsManager.getOptions(yyyfieldconfig)?.find { it.toString() == 'YYY1' }
issue.setCustomFieldValue(yyy, yyyoption);
//Get the ZZZ status field and clear it - ZZZ is a select (single) field
def zzz = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'ZZZ'};
issue.setCustomFieldValue(zzz, null);
//Put AAA in the affects version
Version version = ComponentAccessor.getVersionManager().getVersion(issue.getProjectId(), 'AAA');
issue.setAffectedVersions([version]);
//Stick "CLONE" on the front of the summary
issue.summary = '[CLONE] -' + sourceIssue.summary
//Have to do this after issue creation for some reason
doAfterCreate = {
//Put BBB label on the issue
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def bbblabel = 'BBB'
labelManager.addLabel(user,issue.id,bbblabel,false)
}
UserMessageUtil.success('TEST MESSAGE')Thanks in advance
Neil