Hello,
I have a script listener that should add a comment and mention a user in it but for some reason, even though it adds a comment properly, it doesn't generate a mail for the mentioned user. It's strange, because we have couple of similar listeners/postfunctions and they work in every case except this one. Here is the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventType
def cm = ComponentAccessor.commentManager
def um = ComponentAccessor.userManager
def cprbot = um.getUserByName("cpr_bot")
def components = ["fashion", "teeth", "COMPRESSTOCKING"]*.toLowerCase()
def event = event as IssueEvent
def comBody = "[~drnovseku] prośba o update. Test powiadomienia: [~bugajk]"
def addComment = {
cm.create(event.issue, cprbot, comBody, true)
}
log.warn "DOSTEPY ${event.eventTypeId} ${EventType.ISSUE_UPDATED_ID}"
if (event.eventTypeId == EventType.ISSUE_CREATED_ID) {
if (event.issue.getComponents()*.name.intersect(components).size() > 0) {
cm.create(event.issue, cprbot, comBody, true) //addComment()
}
} else if (event.eventTypeId == EventType.ISSUE_UPDATED_ID) {
def changeLog = event.getChangeLog()
def changeItems = changeLog.getRelated("ChildChangeItem")
def fieldChanged = changeItems.findAll {it.getString('field') == "Component"}
if (fieldChanged.size() > 0) {
def old = fieldChanged*.getString('oldstring')
def nju = fieldChanged*.getString('newstring')
if (components.any {!old?.contains(it) && nju?.contains(it)}) {
cm.create(event.issue, cprbot, comBody, true) //addComment()
}
}
}
Any idea why the users don't receive any notifications from this comment but they receive notifications from mentions anywhere else? Their emails in Jira are correct and they have access for the ticket with comment.
Also the comment itself looks good enough for me:
def comBody = "[~drnovseku] prośba o update. Test powiadomienia: [~bugajk]"
I believe the [~] needs to contain the users email address, not their name.
Hi Ben,
When you're mentioning someone, you need to use their username in [~]. Using e-mail address only creates a comment with an e-mail address but without mentioning anyone:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.