Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-4327

Script Registry does not understand there is an event object in the context of a listener

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Done
    • Affects Version/s: 5.9.1-p5
    • Fix Version/s: 6.17.0
    • Component/s: Built-in Scripts
    • Labels:
    • Sprint:
      SR4J Sprint 90
    • Critical Points:
      1.8

      Description

      Problem

      We will show an error like this in the Script registry for Listeners:

       

      No such property: issue for class: java.lang.Object

       

      when the users refer to a property hanging off the event object because the registry does not seem to understand that the event object, in this case, is an IssueEvent which does have an issue property. So the error is not correct for the context of this listener.

      This can make users think their scripts are wrong when they are not if they use the Script registry to check for errors. The listener itself will show a green tick for this script:

       

      Steps to reproduce:

      • Make a custom script listener that listens for the Issue Created and Issue Updated event with this code in a script file under the <ScriptRoots>/scripts/listener/my_listener_script.groovy
      package listener
      
      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.MutableIssue
      
      def issue = event.issue as MutableIssue
      
      • Refer to the script as a file instead of inline and save the listener
      • The listener will show green when checking the code
      • Run the Script registry built-in script and look for the error reported for this specific listener which should be: "No such property: issue for class: java.lang.Object"

      Notes:

      Using the script inline has the same error as well:

       
      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.MutableIssue
      
      def issue = event.issue as MutableIssue
      

       

       

        Attachments

          Activity

            People

            Assignee:
            twozniak Tomasz Wozniak
            Reporter:
            mclark Matthew Clark
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: