Skip to content

Gloop Gloovy Icon

Gloovy

A Gloovy Step in Gloop is a hybrid between a Groovy script and a Gloop Step (hence the name). Gloovy Steps have complete access to the Gloop variables that are available in the service where the Gloop Step is inserted. If you have some logic that needs to be executed in your Gloop Service which can't be provided with the included Gloop Steps, you have two choices:

A sample Gloop Service using a Gloovy Step

The example above shows a simple Gloovy Step with a function used to calculate Fibonacci numbers count times. In the screenshot, count is 20. Also from the screenshot, you can see the following:

  • On line 1 of the Gloovy step a new function is declared, which is invoked from line 3 and 6.
  • On line 6, the output of the function is being set to a Gloop variable called fibonacciSeries.

The editor for Gloovy Steps is the same as the editor used for Set Expressions.

_Gloovy Step Editor_ in Coder Studio

_Gloovy Step Editor_ in Coder Cloud

It is recommended that you read the Gloop Design Guidelines to help you write more maintainable, reusable code.

Gloovy Scripts in the Gloop Service Editor

In Coder Studio, you can click on the filter button, and toggle the Show Gloovy Script Lines menu item to show and hide Gloovy scripts in the editor. Gloovy lines in Coder Studio

Errors in Gloovy Steps

If your Gloovy Step throws an exception (regardless whether it was from a syntax error or not), Gloop will produce a standard Gloop stacktrace, but with an extra suffix telling you the line number where the error occurred in your Gloovy Step. For example, given the error below, the Gloovy Step at line 7 threw the exception:

1
2
    io.toro.gloop.exception.GloopException: groovy.lang.MissingPropertyException: No such property: error for class: Script1
        at NaughtyGloovy.Gloovy(NaughtyGloovy.gloop:2)[7]

Note the second line in the stacktrace, below, which also has some extra notes on the line underneath:

1
2
3
    at NaughtyGloovy.Gloovy(NaughtyGloovy.gloop:2)[7]
    -----------------------------------------------------------------
                           |     Gloop Service   | Gloovy Line Number 

Here is a screenshot showing the Gloovy Step:

A Gloovy Step with error

Errors in Gloovy Steps

Exceptions are thrown at runtime if your Gloovy Step has a syntax error. Like any other exception, they will be caught by any parent Block Steps with a catch.