We're trying to create a simple Helpdesk workflow with basic Jira (not Service Desk).
Our current setup uses the generic mail handler to "Create new issue or add comment", and we have a "Fast Track transition" listener act upon comments if current status == "To Do", the transition will move the ticket to another state
I noticed that if the email being sent contains only text, then the listener will work and the transition triggers properly. HOWEVER, if the email contains an attachment (or even small images within the email, 5~10kb in size), then the listener does not trigger at all. That particular event does not even show up in the execution history of the listener, even though the comment created from the email appears in the ticket itself.
Anyone know what could cause this?
Hi @ys
Could you please share your code and Listener configuration so I can review it and provide some feedback?
Thank you and Kind regards,
Ram
Hi @ys
I have tried to replicate this issue in my environment, but I don't seem to be encountering the issue. I can transition the issue along with the attachments.
Below is a screenshot of my mail handler configuration:-
Below is the sample code that I have tested with:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.service.services.file.FileService
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.mail.MailUtils
import org.apache.commons.io.FileUtils
def userManager = ComponentAccessor.userManager
def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def commentManager = ComponentAccessor.commentManager
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def jiraHome = ComponentAccessor.getComponent(JiraHome)
def subject = message.subject as String
def issue = ServiceUtils.findIssueObjectInString(subject) as MutableIssue
if (issue) {
return
}
def user = userManager.getUserByName('admin')
def reporter1 = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey('MOCK')
def issueObject = issueFactory.issue
issueObject.setProjectObject(project)
issueObject.setSummary(subject)
issueObject.setDescription(MailUtils.getBody(message))
issueObject.setIssueTypeId(project.issueTypes.find { it.name == 'Bug' }.id)
issueObject.setReporter(reporter1)
issue = messageHandlerContext.createIssue(user, issueObject) as MutableIssue
def attachments = MailUtils.getAttachments(message)
def issueDescription = new StringBuilder(issue.description).append('\n')
attachments.each { it ->
def file = FileUtils.getFile(it.filename) as File
messageHandlerContext.createAttachment(file, it.filename, it.contentType, user, issue)
}
issue.setDescription(issueDescription.toString())
commentManager.create(issue, user, 'This is a sample', true)
issueManager.updateIssue(user,issue, EventDispatchOption.DO_NOT_DISPATCH,false)
log.warn '=======>>>> Mail Read <<<<======='
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
In my environment, I am not using any mail servers. So to test this, I have used the sample code above for this test case to read the *.eml file from the <JIRA_HOME>/import/mail folder.
If you observe in the code, I have included:-
def commentManager = ComponentAccessor.commentManager
...
...
...
commentManager.create(issue, user, 'This is a sample', true)
So once the ticket is created, it will also include a comment, which will automatically cause the issue to transition to the Testing status.
For the Listener, I am using the same configuration that you have shared, i.e.:-
Below are a few test screenshots for your reference:-
1. The email file is added to the <JIRA_HOME>/import/mail as shown below:-
2. Once the mail handler is executed, the mail folder is cleared, and the issue is created, as shown below.
If you observe, the issue is created with attachments and can transition to the Testing status without any issues.
I suggest you try to re-test this in your environment and ensure all your other plugins except for ScriptRunner are temporarily disabled before running the test.
Also, please note that I have run this test with the latest version of ScriptRunner, i.e. 7.4.0.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
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.