Script not running on email created issue

daniel_hedberg March 29, 2016

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
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2016
0 votes
daniel_hedberg March 30, 2016

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

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2016

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

0 votes
daniel_hedberg March 29, 2016

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
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2016

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?

0 votes
daniel_hedberg March 29, 2016

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
daniel_hedberg March 29, 2016

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 

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2016

Version of JIRA and the plugin?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events