Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The groovy script has the following objects / variables available

Variable name

Description

Note

issue

the current issue that the call is operating on

response

the parent response from the previous runned call as String 

jsonSlurper

Use JsonSlurper

Does not work with  Groovy 3.0.7 and OpenJDK 64bit 11.0.13+8 (https://issues.apache.org/jira/browse/GROOVY-9802 )
See workaround below

jsonOutput

Use JsonSlurper

Does not work with  Groovy 3.0.7 and OpenJDK 64bit 11.0.13+8 (https://issues.apache.org/jira/browse/GROOVY-9802 )
See workaround below

scope

all previous defined variables or responses

Example if call A get
name = Peter as json response
then call B that get
the an issue with all its properties

then call C and c wants to access name it can do so by using

Code Block
scope.name


Common Error

Exception in your groovy code java.lang.RuntimeException: Unable to load FastStringService

Workaround

Workaround is to use ObjectMapper instead of JSON Slurper

Parse JSON

Code Block
languagejava
import com.fasterxml.jackson.databind.ObjectMapper
ObjectMapper mapper = new ObjectMapper()
//response is passed in from the parent action
def myRespnse = mapper.readValue(response, HashMap.class)

Produce JSON

Code Block
languagejava
def myList = []
myList.add([email:issue.reporter.emailAddress])
return mapper.writeValueAsString(myList)



See examples

Page Tree
root@self