How delete attachments and change the link direction using Script runner ?

fabio marcelo November 12, 2014

Hi all,

I am using JIRA 4.4.5, and script runner 2.0.7.

I am using the script post-function "Clones an issue and links".

It works perfectly, but i would like that the attachments were not cloned .

In Additional Code i already tried put this :

checkAttachment = {attachment -> false}

But it not worked.

I would like that the attachments were not cloned and that the issue moved  for another project was for a status "Investigating" instead "Open"

 

Please could you help me  ?

 

Best regards

 

Fabio

 

  

2 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.
November 24, 2014

You shouldn't block closing on outbound lines, and the clone and link should create an outbound link. Maybe the direction of your links are the wrong way round... there is a long-running jira bug where the Cloners link descriptions are reversed. This is fixed in a later version of jira... https://jira.atlassian.com/browse/JRA-24563, https://jira.atlassian.com/browse/JRA-24563

fabio marcelo November 25, 2014

Hi Jamie , Thanks for your help. I will try configure the conditions presented in workflow tool box. By the way, the fast track transition only works for some projects. For other the message below is shown: Exception in thread "Thread-xxxx" java.lang.NullPointerException: Cannot invoke method get() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at com.onresolve.jira.groovy.canned.workflow.postfunctions.FasttrackTransition.doTransition(FasttrackTransition.groovy:118) at com.onresolve.jira.groovy.canned.workflow.postfunctions.FasttrackTransition.this$2$doTransition(FasttrackTransition.groovy) at sun.reflect.GeneratedMethodAccessor3623.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78) at com.onresolve.jira.groovy.canned.workflow.postfunctions.FasttrackTransition.this$dist$invoke$1(FasttrackTransition.groovy) at com.onresolve.jira.groovy.canned.workflow.postfunctions.FasttrackTransition$1.methodMissing(FasttrackTransition.groovy) at sun.reflect.GeneratedMethodAccessor3622.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:811) at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1103) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1056) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149) at com.onresolve.jira.groovy.canned.workflow.postfunctions.FasttrackTransition$1.run(FasttrackTransition.groovy:92) at java.lang.Thread.run(Unknown Source) Please could you help me ? Best regards

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.
November 25, 2014

Are you using additional code? I think you should consider upgrading, your jira version is out of support.

fabio marcelo November 26, 2014

Hi Jamie, I removed the additional code and it worked. But this is unstable. For the 3 issues that i used the fast track , only 2 worked. Did you already see it ? Best Regards Fabio

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.
November 14, 2014

If it doesn't work then that version, which is very old, doesn't support selective copying of attachments.

Setting the initial status is also not straightforward, I would try putting a fast-track function on the create step, and checking for the presence of something the Clone function can set.

fabio marcelo November 21, 2014

Hi Jamie, The fast track function worked :). Regarding attachment clone, it worked using a version 1.8.1. How can i change the link direction of the clone issue ? I have a condition in my workflow that only permit close an issue if your clone already was closed. I have two projects A and B. The issues of the Project A shall be blocked by issues of the Project B after the script "Clones an issue and links" . But i have a big problem. Always that i clone an issue of the Project A and move for Project B (through "Clones an issue and links") the issue moved for other Project B is blocked by issue of Project A. So , for closure of the issues from Project B I need delete the previous link and create a new link manually. It doesn´t matter if the link is "blocks" or "is blocked by". Always the issue of Project A blocks the issue of the Project B using the script "Clones an issue and links". How can i fix this ? Can I add any "Additional Code" for that this link direction will be changed ? Best Regards

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.
November 23, 2014

How does it prevent issue A from being closed? This is some additional condition you've added...?

fabio marcelo November 23, 2014

Hi Jamie , I am using the plugin ( com.atlassian.jira.plugin.workflow.blockinglinks). So, in both projects i include this condition for the button "Close" will be shown. The linked issue must have one of the following statuses to allow issue transitions: Closed, $status.getString("name") or $status.getString("name"). Any clue ? Best Regards

Suggest an answer

Log in or Sign up to answer