Adding data in the ctx


(GOPAL) #1


It appears that we can store the data in the ctx.vars for the particular execution context, how do I add it? ( groovy novice). Also, will the information be stored in the watch_history?

Please help, any pointers to script examples for watcher will also help.

Thanks in advance

(Martijn Van Groningen) #2

Any script in a watch can add variables to the context. For example something like this can be added to a script condition: ctx.vars.my_var=5; return ctx.vars.my_var <= 5;

Once a context variable has been defined it is accessible in all places of a Watch that supports scripting. So in the above example the ctx.vars.my_var can also be checked in a script transform elsewhere in the Watch.

Context variables are scoped to the watch execution to are defined in. Context variables aren't stored in the watch history. However when using the execute watch api to test/debug a watch, the context vars can be included in the response if the debug option is specified.

Script condition and ctx.vars
(GOPAL) #3

Thanks. I was expecting that the values get stored in the vars in watch_history and hence was not sure.
That helped.

(GOPAL) #4

Hello Martijn

Where do we specify the debug option?

(Martijn Van Groningen) #5

The execute watch rest api is described here:

But the debug option isn't described there, but you can just append debug=true to the query string of the url.

(GOPAL) #6


(system) #7