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

0 votes

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 

0 votes

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?

 

0 votes

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 Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

498 views 1 15
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot