Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error during script "Could not add component watchers as a notification recipient: 'null' "

Coco _El mejor_
Contributor
July 12, 2019

I want to design a script to create another issue in the project with key "TR" when someone create an issue in the project "TEST". It´s important to create the issue via REST API, in the future i want to use a similar code to create issues in another products different to Jira. The script Listener that I made is executed when the event "Issue Created" occurs. Like this:

import groovy.json.StreamingJsonBuilder

def issueID = issue.getKey()
def issueTypeID = issue.getIssueType()
def issueType = issue.issueTypeObject.name

def authString = "myUser:myPass".getBytes().encodeBase64().toString()

def body_req = [
"fields": [
"project" : [ "key" : "TR" ],
"summary" : "${issue.summary}" ,
"description" : "${issue.description}",
"issuetype" : [ "id" : "${issueTypeID}" ],
"reporter" : [ "name" : "myUser"]
]
]

def baseURL = "MyjiraDomain/rest/api/2/issue/"

URL url

url = new URL(baseURL)

URLConnection connection = url.openConnection()
connection.requestMethod = "POST"
connection.setRequestProperty( "Authorization", "Basic ${authString}" )
connection.doOutput = true
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect()

 The error information is very lazy:

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2019-07-12 16:08:44,132 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-07-12 16:08:44,132 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script> groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.$() is applicable for argument types: (Script215$_run_closure1) values: [Script215$_run_closure1@bc3ab7b] Possible solutions: is(java.lang.Object), any(), get(java.lang.String), use([Ljava.lang.Object;), any(groovy.lang.Closure), wait()at Script215.run(Script215.groovy:17)


 but i found more information in the atlassian-jira.log file:

 

2019-07-12 16:25:31,757 http-nio-8080-exec-47 ERROR myUser 985x146641x1 jzhf78 172.16.1.1 /secure/QuickCreateIssue.jspa [c.r.j.p.i.s.jira.notificationfilter.ObjectUserWatcher] Could not add component watchers as a notification recipient: 'null'

 

It seems to be an error when the event occurs.

1 answer

0 votes
Jan-Peter Rusch
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.
August 7, 2019

Hi,

are you sure that the errors are related to each other?

The error logged in atlassian-jira.log seems to be thrown by the addon Insight from Riada (c.r.j.p.i com.riadalabs.jira.plugins.insight).

Best

JP

Coco _El mejor_
Contributor
August 8, 2019

Exactly,the Insight error was not related with the main problem. I don´t remember exactly how I fixed it.  I create the JSON object manually, something like this:

 

 def body_req = """{
"fields": {
"project" : { "key" : "TR" },
"issuetype" : { "name" : "${-> issueType}" },
"summary" : "${-> summary}",
"description" : "${-> description}"
}
}"""

 This work for me, but I want to change it to my previus version. I need to map xml fields to a new JSON body. Using the string make hard for me to add new fields. 

 

 

 

Do you know if this works?

def body_req = [
"fields": [
"project" : [ "key" : "TR" ],
"summary" : "${issue.summary}" ,
"description" : "${issue.description}",
"issuetype" : [ "id" : "${issueTypeID}" ],
"reporter" : [ "name" : "myUser"]
]
]

cheers,

 

Agustín.-

Suggest an answer

Log in or Sign up to answer