Questions tagged [groovyshell]

The term groovyshell refers to both: 1. A command line interactive groovy shell, usually invoked as "groovysh" 2. One of the primary classes (groovy.lang.GroovyShell) in the Groovy language API for dynamically compiling and invoking groovy scripts from their raw source state.

The term groovyshell refers to both:

  1. A command line interactive groovy shell, usually invoked as "groovysh"
  2. One of the primary classes groovy.lang.GroovyShell) in the Groovy language API for dynamically compiling and invoking groovy scripts from their raw source state.

Groovysh

A command line groovy interpreter, well documented in the official documentation.

GroovyShell (the class)

groovy.lang.GroovyShell is one of the core classes of the Groovy runtime. It provides support for interpreting, evaluating and compiling groovy scripts in their raw source state. The base support for source read targets are:

  1. Java Files
  2. Java Input Streams
  3. Java Readers
  4. Java Strings
  5. Groovy GroovyCodeSources (A special source construct that isolates the contained source and generated byte code)
247 questions
0
votes
1 answer

Groovysh use custom command inside loop

I have a groovysh issue, where I've noticed that you can't use goovysh commands inside a loop context or inside functions. It seems that the commands get evaluated at parse time instead of runtime. Is there some magic syntax to work around…
Joel Pearson
  • 1,622
  • 1
  • 16
  • 28
0
votes
1 answer

Enabling intellisense in groovysh

Is it possible to enable intellisense in groovysh, in similar lines of what python offering? Code completion feature is not working in groovysh at all. So far there was a myth that command arrows will not work. But after refering documentation and…
0
votes
1 answer

How to set gdsl groovy script base object

Have main java class evaluating groovy scipt Binding binding = new Binding(); binding.setProperty("text", "some text"); CompilerConfiguration configuration = new…
dmitryvim
  • 1,983
  • 4
  • 15
  • 27
0
votes
1 answer

Optional parameter in Groovy Script

I have a script that simply does // TODO: assign default value if not defined println optionalParameter When I invoke it using: new GroovyShell(new Binding([optionalParameter: 'text'])).evaluate(script) it works fine. But if I run it without a…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
0
votes
1 answer

Syntax error in groovy script - what is wrong?

I am trying to execute the following groovy script snippet in my elasticsearch dsl scripting: [doc['availabilities.start'], doc['availabilities.end']].transpose().any { (start, end) -> end.date.getMillis() >= 11 } return 2; ``` and this throws the…
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
1 answer

Retrieve value in map by key in Groovy

def text= ''' 2016-10-18_20_34-46-_server-21.000.409_client-21.000.407.zip 2016-10-18_21_57-33-_server-21.000.409_client-21.000.407.zip
user1888955
  • 626
  • 1
  • 9
  • 27
0
votes
2 answers

How to get all the *.sln files from a given directory using Groovy script?

Am writing a Jenkins Groovy script file to get all the .NET project solution files (*.sln) in a given directory (including subdirectories). First I tried to get the list of directories in a given path. I used the below code which is working…
0
votes
1 answer

Error while calling groovy from java

I am trying to execute a groovy script from Java. Here is what I am trying to do: public class ScriptExecutor{ private ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); public CompiledScript compileScript(String…
Prasanth
  • 1,005
  • 5
  • 19
  • 39
0
votes
1 answer

Execute groovy script in java project, why the operator “>” is converted to ">"?

This is my groovy script: def map = ["curr_dept":codes.get("ICU_DEPT").value]; def list = getActLists(visit,"TRAN",map,[]); boolean flag = false; if(null!=list && list.size()>=1){ return true; } return false; This is my java code for executing…
Rocky Yu
  • 23
  • 4
0
votes
2 answers

How to make ssh connection in workflow through groovy script by using sand box in Jenkins?

How to make ssh connection in workflow through groovy script by using sand box in Jenkins? we need to make a ssh connection to a server and run particular script on that server with a particular user id.. is there any way to do that?
0
votes
1 answer

Remap keys for groovysh when opened in ConEmu

Previous Title: Groovy shell settings/config file location on windows and an example Where can I find/create a groovysh/groovy shell settings/config file in Microsoft Windows 7? Groovysh currently has an issue GROOVY-6453 where certain keys don't…
Lifeweaver
  • 986
  • 8
  • 29
0
votes
1 answer

Parsing json 2 levels down with JsonSlurper - groovy

I've json response that I parsed it and looked at its keyset, like below . It only gives me 3 keysets. Why is it only making key-value pairs of 3 keysets? How do I retrieve values of fields that are two or more levels down? Json looks like this(…
user1207289
  • 3,060
  • 6
  • 30
  • 66
0
votes
1 answer

Reference things from imported class in groovysh

Say I have a SomeThings.groovy file: def someVar = 'abc' def someFunc(a) { a + 1 } I start groovysh with the above file on the classpath and do: groovy:000> import SomeThings ===> SomeThings groovy:000> All good. However: groovy:000>…
levant pied
  • 3,886
  • 5
  • 37
  • 56
0
votes
2 answers

How can I pass a class to Groovy's Eval binding?

I'm doing some gross stuff, like using Groovy's metaClass and Eval to dynamically assign properties to an object from an XML import: class ObjectBuilder { def assignProp(String propName, String propValue) { Eval.x(this,…
techHenson
  • 93
  • 1
  • 5
0
votes
1 answer

Evaluating files with embedded code using Groovy Shell

I'm a web developer that recently moved from using PHP to Java for web applications. I ended up writing my own server application that was easily extendable using uncompiled groovy scripts that my server would evaluate through a Groovy Shell -- ie.…