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

Version of JIRA and the plugin?

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 

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 

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?

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?

 

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

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 Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

58 views 3 2
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