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

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

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

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.

0 votes

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

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")

 

 

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

Yes, definitely it is from JMWE

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;

 

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');

Forget MutableIssue tip, and replace Return with return

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

34 views 0 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