How do you call json data from a Data Step?

27 views
Skip to first unread message

강성규

unread,
Aug 28, 2024, 5:29:29 AMAug 28
to rundeck-discuss
If there was a single Key:Value, command could retrieve value from ${stub.<key>} and script could retrieve value from @stub.<key>@.

However, if the key has a depth of more than 1, the value could not be retrieved from the stub.

The official documentation doesn't say anything about it.

I've searched and searched, but I can't find any reference.

Please help me.

I am sharing the job I ran and the capture.

I sincerely hope you can take a look and help me.

2024-08-28 18 25 30.png
test.yaml

rac...@rundeck.com

unread,
Aug 28, 2024, 9:40:47 AMAug 28
to rundeck-discuss

Hi!

Please take a look at the JQ-JSON logfilter filter plugin here, it’s designed for this use case. Let me share an job example with this plugin:

- defaultTab: nodes description: '' executionEnabled: true id: 7c996dc1-47f7-4095-987c-65c5e649432c loglevel: INFO name: newtest nodeFilterEditable: false plugins: ExecutionLifecycle: {} scheduleEnabled: true sequence: commands: - plugins: LogFilter: - config: extraQuotes: 'false' filter: . logData: 'true' prefix: result type: json-mapper script: |- echo "{ \"a1\": { \"project\": \"2020\", \"instance\": \"spanner\" }, \"a2\": { \"project\": \"2021\", \"instance\": \"driver\" }, \"a3\": \"test\" }" - exec: echo ${data.a3} - exec: echo ${data.a1.project} keepgoing: false strategy: node-first uuid: 7c996dc1-47f7-4095-987c-65c5e649432c

Check the result here (tested on Rundeck 5.5.0)

Please look at this doc entry to learn how to install no-bundled plugins (basically, download the jar file located here and save it on the $RDECK_BASE/libext directory, you don’t need to restart the Rundeck instance).

Hope it helps!

Reply all
Reply to author
Forward
0 new messages