I'm trying to use scriptrunner's clone issue post function. Since the destination project has component as a required field, I need to set the component.
I have the component ID and am okay with hardcoding it in the script. Anyone know how i would accomplish this?
I've tried the following so far:
issueInput.fields.components += {id: "12345"}
issueInput.fields.components = [id: "12345"]
Both result in the following error:
2018-05-18 21:37:56.342 ERROR - Infinite recursion (StackOverflowError) (through reference chain: java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.LinkedHashMap["issueInput"]->java.util.LinkedHashMap["fields"]->java.util.LinkedHashMap["components"]->java.util.ArrayList[0]->_run_closure1["delegate"]->Script1["binding"]->groovy.lang.Binding["variables"]->java.util.L 2018-05-18 21:37:56.502 ERROR - Class: com.adaptavist.sr.cloud.workflow.CloneIssue, Config: [className:com.adaptavist.sr.cloud.workflow.CloneIssue, uuid:redacted, description:Clones to Project, enabled:true, condition:, issueTypeId:, projectId:1234, executionUser:INITIATING_USER, linkTypeId:10001, linkDirection:Inward,
It looks like it's running into an infinite loop when serializing the component field? Is this a bug or am I missing something?
Hi Randy,
The components field is an array so to set the value you require, you should use syntax similar to the example show below where you specify the component by its name using a name, value pair.
issueInput.fields.components = [[name: '<ComponentNameHere>']]
If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.
Regards,
Kristian
That did it. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any idea how you do this so that you can add a new component without overwriting any components that are already there? I have a use case where I want to be able to add multiple components either through scripts or by the users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@E01807 you can read from the components field, add to the array, then set the array to the issueInput component field as Kristian showed above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This might work. Note that it's untested. Assumes Issue and issueInput are available in the script context as bindings
def newComponentList = issue.fields.components.clone()
newComponentList.add([name: 'New Component'])
issueInput.fields.components = newComponentList
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.