Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

printing variable inside string allowed in Insight Script Console but not in Insight Groovy Script

Beppe Marcon January 30, 2019 edited

Hello, I'm using Insight version 5.6.2 and Jira.

I'm experiencing different behaviours when running groovy code inside "Insight Script Console" which I can reach by going in "Apps" >>"Insight">>"Insight Script Console"  and when running the same groovy code inside "Insight Groovy Script" which I can reach by clicking "Edit Workflow" >> transition properties >> "postfunctions" >> "Insight Groovy Script" in Jira.

For instance the following SSCCE (short, self contained, correct example) code:

package myapp

import org.apache.log4j.Level
import org.apache.log4j.Logger

public class MySuperApp
{
Logger log

MySuperApp() {
log = Logger.getLogger("net.MySuperApp")
log.setLevel(Level.DEBUG)
}

public void funx(String myParam) {
log.debug("running fun: ${myParam}")
}
}
MySuperApp app = new MySuperApp()
app.funx("hello")

returns an error in Insight Groovy script only:

Caught exception while attempting to perform action 11 from workflow 12009 on issue 'SU-762'
com.opensymphony.module.propertyset.PropertyImplementationException: Property 'myParam' not found

the reason is that ${myParam} somehow is not understood as correct syntax but I should instead opt for String concatenation, for instance:

log.debug("running fun: "+myParam)

The questions are:

  • why "Insight Script Console" and "Insight Groovy Script" don't behave the same? do they use different interpreters?
  • why the ${varName} syntax which is accepted by Groovy language specifications is not allowed in Insight Groovy Scripts? doesn't it support all Groovy syntax rules?

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events