Script not running on email created issue

Hi

 

 

I have an issue with a script that i have designed for Jira.

 

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
def attachmentManager = ComponentAccessor.getAttachmentManager()
log.debug "--------- DELETE ATTACHMENTS ---------"
attachmentManager.getAttachments(event.issue).each { 
if (it.getFilesize() <= 9000 && (it.getFilename().endsWith(".png") || it.getFilename().endsWith(".jpg") || it.getFilename().endsWith(".gif"))) {
attachmentManager.deleteAttachment(it)
}
}

 

 

This script is the listener its suppose to remove attachments of certain types and size. The issue is that it does not do this when an issue is created via email. It works perfectly when i create an issue in JIRA but not when creating an issue via an email. It executes but it does nothing. 

 

Regards

 

8 answers

This widget could not be displayed.

Version of JIRA and the plugin?

This widget could not be displayed.

JIRA Software 7.0.10 and JIRA Service Desk 3.0.10 and Scriptrunner Installed version:

4.2.0.5

The issue is with a workflow in Servicedesk 

This widget could not be displayed.

FYI i also tried running it as a post function in the create issue workflow. Same results it works fine when creating the issue but when creating issue via email the script is run but no action is taken 

This widget could not be displayed.

The problem is that the attachments are not available to the post-function at the time it runs, when creating an issue via email. This is a JIRA bug, imho. What is the position of the post-function, ie, can you try making it last?

This widget could not be displayed.

Hi

I tried now to both move the script to the end of the transition after the generic event is fired no change. It still runs but no action is taken on the attachments

Please see the payload

{
    "full.module.key": "com.onresolve.jira.groovy.groovyrunnerrungroovy-function (java.lang.String)",
    "canned-script": "com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction (java.lang.String)",
    "class.name": "com.onresolve.jira.groovy.GroovyFunctionPlugin (java.lang.String)",
    "issue": "MERCURDESK-435 (com.atlassian.jira.issue.IssueImpl)",
    "passesCondition": "true (java.lang.Boolean)",
    "transientVars": {
        "entry": "com.opensymphony.workflow.spi.SimpleWorkflowEntry@6819945a",
        "issue": "MERCURDESK-435 (com.atlassian.jira.issue.IssueImpl)",
        "configuration": "com.opensymphony.workflow.config.DefaultConfiguration@3b24999",
        "context": "com.opensymphony.workflow.basic.BasicWorkflowContext@7a26a513",
        "createdStep": "SimpleStep@8[owner=, actionId=0, status=Open] (com.opensymphony.workflow.spi.SimpleStep)",
        "actionId": "1 (java.lang.Integer)",
        "currentSteps": "[SimpleStep@8[owner=, actionId=0, status=Open]] (java.util.ArrayList)",
        "pkey": "MERCURDESK (java.lang.String)",
        "store": "com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@499c3322",
        "descriptor": "com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@4ac9db8b"
    },
    "log": "org.apache.log4j.Logger@71976318"
}

 

How would you suggest i proceed?

 

This widget could not be displayed.

I would suggest you proceed by trying a listener on Issue Created, or a scheduled service that does this.

This widget could not be displayed.

I have already tried to schedule a listner for issue created the result was the same what do you mean by a scheduled service?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

304 views 1 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you