I'm running the Rundeck community edition (3.4.3 2021-08-23). I have a (winRM) Powershell command step that creates a simple JSON output.
@{Hello="World";Simple="Test"} | ConvertTo-Json
In this step #1, I have the "JSON jq key/value mapper" added.
The following step #2 is a simple output. Running as (winRM) Powershell command. Just writing the variable output.
Write-Output "$result.Simple"
Once I run it I can see JSON is produced in step #1 and correctly parsed by the log filter. If I try to access the variable value in step #2 it's empty and produces "No output".
Both steps 1 and 2 ok. But variable empty. No output from step #2.
I had success using the Log Filter "Key Value Data" and "Multiline Regex Data Capture". But the "JSON jq key/value mapper" seems to work differently. I have also tried with upper and lowercase variable names. With "result", "data" and without prefix in the LogFilter configuration. But I can't get around to how to access the data in the variables.
Log Filter: https://resources.rundeck.com/plugins/jq-json-log-filter/
Use ${data.name}
for the command step or @data.name@
for script step. I made a basic example that gets the value from a JSON file.
Rundeck job definition:
- defaultTab: nodes
description: ''
executionEnabled: true
id: fb6042da-5e4c-46d2-a2c1-d3a486ce019f
loglevel: INFO
name: JSONHelloWorld
nodeFilterEditable: false
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- exec: cat /Users/myuser/Desktop/example.json
plugins:
LogFilter:
- config:
filter: .
logData: 'true'
prefix: result
type: json-mapper
- exec: echo ${data.firstName}
keepgoing: false
strategy: node-first
uuid: fb6042da-5e4c-46d2-a2c1-d3a486ce019f
Check the result.