This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Python Task return Json || Parse in orquesta workflows

hi Team

in my workflow, calling one of the Python script tasks & got the stdout as JSON format.

stdout: ‘{’‘short_description’’: ‘‘host1 is not responding to Ping’’, ‘‘description’’: ‘‘host1 is not re
sponding to Ping’’, ‘‘cmdb_ci.name’’: ‘‘host1’’, ‘‘state’’: ‘‘7’’, ‘‘assignment_group.name’’: ‘‘Wintel L1’’}

we need to parse the json values inside the workflow. i have tried to get the description as below

  • inc_description: “{{ result().stdout.description }}”
    however i got an error - - message: ‘JinjaEvaluationException: There are unresolved variables: result().stdout.description’

Please help.

tasks:
Collecting_info:
action: arul_automation.GetIncident
input:
Incident_Number: “{{ ctx().incident_no }}”
Field_name: “number,description,short_description”
next:
- when: “{{ succeeded() }}”
publish:
- inc_description: “{{ result().stdout.description }}”
- error_message: “{{ result().stderr }}”
do:
- noop
- when: “{{ failed() }}”
publish:
- error_message: “Could not get the details for this incidnet {{ ctx().incident_no }}”
do:
- noop

It’s difficult to say without seeing the output from the first task.

But it indicates that it can’t find description under stdout.

What you see in the return from "st2 execution get " under the result field, is what result() should return, and be able to handle.

Some things to check:

  • Check stdout is at the level you expect, and not at something like result().result.stdout
  • Check that it is being picked up as JSON (in execution get - has it unpacked it as JSON), I’ve known some tasks return a string encoding of the JSON rather than the JSON itself
  • Perhaps start higher up with your variables, e.g. check what result() returns, then result().stdout - to see exactly what you are getting.