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

Component Events Ignore the Project selection filter field on the Listener configuration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Done
    • Low
    • Resolution: Done
    • 5.5.7
    • 6.10.0
    • Script Listeners
    • None
    • SR4J Sprint 80, SR4J Sprint 81, SR4J Sprint 82, SR4J Sprint 83, SR4J Sprint 84, SR4J Sprint 85
    • 4.8

    Description

      The Projects selection field in the listener configuration screen is ignored if the event that triggers the listener is a "component event" such as the "ProjectComponent Event".
      We currently only acknowledge the Project Selection field for Issue events, worklog events and version events.

      We should add the component events to the list of events that consider the project selection field, and it would also be good to notify users when the selected event ignores the project select field.

      Steps to reproduce

      1. Create a custom listener and set the event to the "ProjectComponentCreatedEvent"
      2. Set a specific Project in the "Project(s)" filter field
      3. Create a Component in a project you did not include in listeners the "Project(s)" filter
      4. You should see the Listener still gets triggered.

      Workaround

      A possible workaround would be to detect the project name within the actual script and then use if blocks to make sure the script logic only runs for your wanted projects.

      Example Custom Listener script:

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.project.Project
      import com.atlassian.jira.project.ProjectManager
      import org.apache.log4j.Level
      import org.apache.log4j.Logger
      def log = Logger.getLogger(getClass())
      log.setLevel(Level.DEBUG)
      
      ProjectManager projectManager = ComponentAccessor.getProjectManager()
      
      def triggeringProjectName = event?.getProjectComponent()?.getName()
      def triggeringProjectId  = event?.getProjectComponent()?.projectId
      
      if(triggeringProjectId){
      
          Project myProject = projectManager.getProjectObj(triggeringProjectId)
      
          log.debug("Project name where event came from = " + triggeringProjectName)
          log.debug("Project ID = " + triggeringProjectId)
          log.debug("Project Object = " + myProject)
      
          //perform your logic in here
      
      }else{
          log.debug("Project Name not found")
      }
      

       

       

       

       

      Attachments

        Issue Links

          Activity

            People

              mclark Matthew Clark
              mclark Matthew Clark
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: