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

The IssueLinkCreatedEvent and IssueLinkDeletedEvent is triggered even if the Project is not Included into the Listener's Project Field

    Details

    • Type: Bug
    • Status: Done (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 5.6.14, 6.3.0, 6.2.1-p5
    • Fix Version/s: 6.10.0
    • Component/s: Listeners
    • Labels:
      None
    • Sprint:
      SR4J Sprint 82, SR4J Sprint 83, SR4J Sprint 84, SR4J Sprint 85
    • Critical Points:
      5.4

      Description

      Steps to Reproduce

      1. Create a new Listener, select the Project(s) that will be used for the Listener and for the Event, select IssueLinkCreatedEvent and IssueLinkDeletedEvent
      2. In the Script field add a basic Logger code i.e.
        import com.atlassian.jira.component.ComponentAccessor
        import com.atlassian.jira.issue.Issue
        import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
        import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
        import com.atlassian.jira.issue.ModifiedValue
        import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
        import com.atlassian.jira.event.type.EventDispatchOption
        
        def evantValue = event.class.toString()
        
        def issue
        def issue2
        
        if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent") {
            def issueLinkCreated = event as IssueLinkCreatedEvent
            issue = issueLinkCreated.issueLink.sourceObject
            issue2 = issueLinkCreated.issueLink.destinationObject
            log.warn "---->>> Triggered by ${issue2.key}"
        
        } else if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent") {
            def issueLinkDeletedEvent = event as IssueLinkDeletedEvent
            issue = issueLinkDeletedEvent.issueLink.sourceObject
            log.warn "---->>> Triggered by ${issue.key}"
        
        } else {
            log.warn "Noting to do"
        }
           

      Below is print screen of the configuration:-

      Current Behaviour

      In the print screen above, I have configured only 3 project for the Listener i.e. Nasdaq Mock, Nasdaq TEST and Nasdaq Bug and the Listener works as expected on them.

      Below is a print screen for more information:-

      However, if I test the Listener on another Project which is not included in the Listener configuration's Project(s) field, it still triggers the event.

      Below is a print screen for more information:-

      Expected Behaviour

      The listener is expected to trigger accordingly only for the Projects that have been included in the Project(s) field.

      Workaround

      In the if /else condition, include another if/else filter of the project keys i.e. from

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.Issue
      import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
      import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
      import com.atlassian.jira.issue.ModifiedValue
      import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
      import com.atlassian.jira.event.type.EventDispatchOption
      
      def evantValue = event.class.toString()
      
      def issue
      def issue2
      
      if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent") {
          def issueLinkCreated = event as IssueLinkCreatedEvent
          issue = issueLinkCreated.issueLink.sourceObject
          issue2 = issueLinkCreated.issueLink.destinationObject
          log.warn "---->>> Triggered by ${issue2.key}"
      
      } else if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent") {
          def issueLinkDeletedEvent = event as IssueLinkDeletedEvent
          issue = issueLinkDeletedEvent.issueLink.sourceObject
          log.warn "---->>> Triggered by ${issue.key}"
      
      } else {
          log.warn "Noting to do"
      }
      

      to

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.issue.Issue
      import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
      import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
      import com.atlassian.jira.issue.ModifiedValue
      import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
      import com.atlassian.jira.event.type.EventDispatchOption
      
      def evantValue = event.class.toString()
      
      def issue
      def issue2
      
      if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent") {
          def issueLinkCreated = event as IssueLinkCreatedEvent
          issue = issueLinkCreated.issueLink.sourceObject
          issue2 = issueLinkCreated.issueLink.destinationObject
      
          if( (issue.projectObject.key == "ILT" || issue.projectObject.key == "BT") &&  (issue2.projectObject.key == "ILT" || issue2.projectObject.key == "BT") ) {
            log.warn "---->>> Triggered by ${issue2.key}"
          } else { 
             return
          }
      
      } else if (evantValue == "class com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent") {
          def issueLinkDeletedEvent = event as IssueLinkDeletedEvent
          issue = issueLinkDeletedEvent.issueLink.sourceObject
          issue2 = issueLinkDeletedEvent.issueLink.destinationObject
      
          if( (issue.projectObject.key == "ILT" || issue.projectObject.key == "BT") &&  (issue2.projectObject.key == "ILT" || issue2.projectObject.key == "BT") ) {
           log.warn "---->>> Triggered by ${issue.key}"
           } else {
            return
           }
      
      } else {
          log.warn "Noting to do"
      }
      

        Attachments

        1. listener_config2.png
          listener_config2.png
          180 kB
        2. print_screen_1.png
          print_screen_1.png
          190 kB
        3. screenshot.png
          screenshot.png
          170 kB

          Structure

            Activity

              People

              Assignee:
              twozniak Tomasz Wozniak
              Reporter:
              rkumar Ram Kumar Aravindakshan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Structure Helper Panel