Details
-
Bug
-
Status: Done
-
Major
-
Resolution: Done
-
5.6.14, 6.3.0, 6.2.1-p5
-
None
-
SR4J Sprint 82, SR4J Sprint 83, SR4J Sprint 84, SR4J Sprint 85
-
5.4
Description
Steps to Reproduce
- Create a new Listener, select the Project(s) that will be used for the Listener and for the Event, select IssueLinkCreatedEvent and IssueLinkDeletedEvent
- 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" }