Hi everyone:
I need to send a notification via slack when a comment is created for an issue.
I was able to send a message using Scriptrunner Listener "Post a message to Slack".
However, I can't send comment that has been created as part of the message.
My Code is:
<% out << currentUser?.displayName %> comentó en el ticket
https://mda.neora.com.pe/browse/${issue.key}
${issue.key}: ${issue.summary}
This works fine, but when I added the next code:
<% if (lastComment)
out << lastComment
%>
I got an error. Log shows:
groovy.lang.MissingPropertyException: No such property: lastComment for class: groovy.lang.Binding
2020-05-23 01:47:23,924 http-nio-8091-exec-17 ERROR oscar.diaz 107x2234272x1 2etzel 190.234.91.39,127.0.0.1 /rest/api/2/issue/CRO-145/comment [c.o.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.PostMessageToChatService
2020-05-23 01:47:23,924 http-nio-8091-exec-17 ERROR oscar.diaz 107x2234272x1 2etzel 190.234.91.39,127.0.0.1 /rest/api/2/issue/CRO-145/comment [c.o.scriptrunner.runner.AbstractScriptListener]
I also have tried with:
<% if (mostRecentComment)
out << mostRecentComment
%>
But get the same error, the only difference is this part:
groovy.lang.MissingPropertyException: No such property: mostRecentComment for class: groovy.lang.Binding
I spent the last 24 hours trying to figure out how send comment via slack when a comment is created for an issue. Something that seems to be so basic, but I can't make it to work.
Please, your kindly help.
Thanks in advance,
Tito.
The Binding is the context that includes all the variables defined for the script.
Adaptavists makes sure some commonly used variable are available. That's how you're able to just use "currentUser".
But there is no such thing in this binding as lastComment or mostRecentComment
But if you are listening for the Issue Commented event, the event variable includes the comment that raised the event.
So you could do something like this (with some additional formatting suggestions and binding manipulation to do more advanced scripting in the condition block and pass the new variable to the template:
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.