Groovy Script silently does nothing, I don't know where the logs are to diagnose. is there a log created for groovy errors?

Deleted user February 24, 2015

Groovy Script silently does nothing, I don't know where the logs are to diagnose. is there a log created for groovy errors?

The value of field Supplier Re-evaluation Date of the current issue will be set to the result of a Groovy expression (replacing existing values).

import static java.util.Calendar.YEAR;
def year = new Date();
if(issue.get("Priority")=="Critical")

{ def year = today[YEAR] + 1 }

else if(issue.get("Priority")=="Major")

{ def year = today[YEAR] + 2; } else if(issue.get("Priority")=="Minor"){ def year = today[YEAR] + 2; }

else if(issue.get("Priority")=="Trivial")

{ def year = today[YEAR] + 3; }

else

{ def year = today[YEAR]; }

year.format('dd/MMM/yy');
Return year;

6 answers

0 votes
Jozef Kotlár
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.
February 25, 2015

Forget MutableIssue tip, and replace Return with return

0 votes
Deleted user February 25, 2015

updated script: only errors on line #1

MutableIssue issue = binding.variables.get("issue") as MutableIssue ?: com.atlassian.jira.component.ComponentAccessor.issueManager.getIssueObject("QS-63883") import static java.util.Calendar.YEAR; def year = new Date(); if(issue.get("Priority")=="Critical"){ year = today[YEAR] + 1 } else if(issue.get("Priority")=="Major"){ year = today[YEAR] + 2; } else if(issue.get("Priority")=="Minor"){ year = today[YEAR] + 2; } else if(issue.get("Priority")=="Trivial"){ year = today[YEAR] + 3; } else { year = today[YEAR]; } PrintIn year.format('dd/MMM/yy');

0 votes
Deleted user February 25, 2015

please forgive me I am a beginner in groovy & Jira. if I am mixing languages, please let me know. I am working in Jira on a transition, attempting to run a groovy script to take the input of a field at release(priority) & add to today's date by year based on that & fill a referenced field in the current document with a date.

 

my transition type: "The value of field (field name) of the current issue will be set to the result of a Groovy expression (replacing existing values)."

here is the error that I get running the script in "script console"(original script)

@ line 15, column 8.
   Return year;
          ^

Script2.groovy: 15: unable to resolve class Return 
 @ line 15, column 8.
   Return year;
          ^

 

errors adding mutuableissue line:

 

 @ line 16, column 8.
   Return year;
          ^

Script6.groovy: 1: unable to resolve class MutableIssue 
 @ line 1, column 14.
   MutableIssue issue = binding.variables.get("issue") as MutableIssue ?: com.atlassian.jira.component.ComponentAccessor.issueManager.getIssueObject("QS-63883")
                ^

Script6.groovy: 1: unable to resolve class MutableIssue 
 @ line 1, column 53.
   inding.variables.get("issue") as Mutable
                                 ^

Script6.groovy: 16: unable to resolve class Return 
 @ line 16, column 8.
   Return year;

 

0 votes
Jozef Kotlár
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.
February 24, 2015

Your script is failing - you cannot overwrite year with another def. Remove all defs, but the first.

Try your script in Script Console with following snippet at the beginning to work with existing issue (replace key XYZ-333):

MutableIssue issue = binding.variables.get("issue") as MutableIssue ?: com.atlassian.jira.component.ComponentAccessor.issueManager.getIssueObject("XYZ-333")

 

 

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.
February 24, 2015

All true, but this: issue.get("Priority") is only valid with JWME afaik

Jozef Kotlár
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.
February 25, 2015

Yes, definitely it is from JMWE

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.
February 24, 2015

I think this question is actually about JMWE and not script runner, you might want to change your tags.

0 votes
kitkat
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 24, 2015

Here is information related to groovy logging:

https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner#ScriptRunner-Logging

Typically, you see the logging for groovy in the <JIRA-HOME>/log/atlassian-jira.log file. Please reference this link for adjusting the logging level for your goovy scripting.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events