We have a custom script listener, which listens IssueLinkCreatedEvent in one single project.
However, the listener does not respect the project setting. The script got triggered by other project as well, and I do not see any relationship between these projects.
Any suggestions?
Thanks!
You'll have to show us your code so that we can check if there's something wrong with it.
The script itself is pretty straight forward: listening the IssueLinkCreatedEvent and send email, and it works. The problem is that I only want this script be triggered in one project, but it ends up got triggered by all projects even though only project key is selected from the project key list.
Any thoughts?
Following are the script and screenshot of listener setting:
import javax.mail.*
import javax.mail.internet.*
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
def subject = "New Issue Link Has Been Created"
def content = "New Issue Link Has Been Created"
def port = 25
def props = new Properties()
props.put('mail.smtp.host', 'ourmailhost.com')
props.put('mail.smtp.port', port.toString())
def session = Session.getDefaultInstance(props, null)
def msg = new MimeMessage(session)
def to = new InternetAddress('my@email.com')
msg.from = new InternetAddress('nobody@email.com')
msg.sentDate = new Date()
msg.subject = subject
msg.setRecipient(Message.RecipientType.TO, to)
msg.setContent(content, "text/html; charset=utf-8")
Transport.send(msg)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try wrapping your code in this closure:
if (event.issue.getProjectObject().getKey() == "your project key"){
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ivan,
Thanks for the reply! I'll try that.
That is strange that the project key section in listener setting does not take effect, and we have to wrap project key condition check inside our script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd suggest contacting add on vendor for that. Perhaps it might be a bug.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I agree this is not going to work as expected. The issueLink[Created|Deleted]Events are not executed in the context of an issue but in the context of an issue link.
I've just stumbled across this same issue and have discovered that these event types do not extend/inherit from com.atlassian.jira.event.issue.IssueEvent but according to Atlassian API it's extended from the generic object type.
I wanted to limit the listener to only specific projects configured in the listener but there's no way it can know that information. Only check I can do is to examine both sides of the link, look at the keys and determine their issue type / project key and make an intelligent assumption...and assumptions are the mother of all **** :(
Don't see this as a scriptrunner bug as such, I think it's just the way that Atlassian have decided to implement. It would be great if these link events could have some information on the issue context which they have been invoked from. This is probably do-able from within the UI (where you're managing links from a specific issue) but definitely wouldn't work in the API/REST where the abstraction takes that information away.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.