Argo workflows - Workflow variable Invalid Json format #10082
Unanswered
sharadhirao
asked this question in
Q&A
Replies: 1 comment
-
According to the Argo Workflows documentation, the output JSON is correct.
When running this workflow, this is the output I get from the exit handler: [{"displayName":"argo-workflow-jvhpb","message":"","templateName":"Argo-Config-Checkout","phase":"Failed","podName":"argo-workflow-jvhpb","finishedAt":"2024-12-02T15:28:13Z"},{"displayName":"check-env","message":"Error (exit code 1)","templateName":"check-env","phase":"Failed","podName":"argo-workflow-jvhpb-check-env-4255976317","finishedAt":"2024-12-02T15:28:04Z"}]
time="2024-12-02T15:28:20 UTC" level=info msg="sub-process exited" argo=true error="<nil>" To convert to valid JSON, you could use either of these methods: # Using toJson() built in Argo Workflows function
args: ["echo '{{=toJson(workflow.failures)}}'"] # converts to JSON
# Using tr
args: ["echo '{{workflow.failures}}' | tr -d '\\n'"] # Removes new lines Outputs: # toJson() output
"[{\"displayName\":\"argo-workflow-pm2dr\",\"message\":\"\",\"templateName\":\"Argo-Config-Checkout\",\"phase\":\"Failed\",\"podName\":\"argo-workflow-pm2dr\",\"finishedAt\":\"2024-12-02T15:50:20Z\"},{\"displayName\":\"check-env\",\"message\":\"Error (exit code 1)\",\"templateName\":\"check-env\",\"phase\":\"Failed\",\"podName\":\"argo-workflow-pm2dr-check-env-76813750\",\"finishedAt\":\"2024-12-02T15:50:18Z\"}]"
# tr output
"\"[{\\\"displayName\\\":\\\"check-env\\\",\\\"message\\\":\\\"Error (exit code 1)\\\",\\\"templateName\\\":\\\"check-env\\\",\\\"phase\\\":\\\"Failed\\\",\\\"podName\\\":\\\"argo-workflow-4j5fh-check-env-3055544644\\\",\\\"finishedAt\\\":\\\"2024-12-02T15:37:48Z\\\"},{\\\"displayName\\\":\\\"argo-workflow-4j5fh\\\",\\\"message\\\":\\\"\\\",\\\"templateName\\\":\\\"Argo-Config-Checkout\\\",\\\"phase\\\":\\\"Failed\\\",\\\"podName\\\":\\\"argo-workflow-4j5fh\\\",\\\"finishedAt\\\":\\\"2024-12-02T15:37:51Z\\\"}]\"" Resources |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Team,
I was trying to get the {{workflow.failures}} variable. When I output it Its giving me invalid json format. What I am doing is :
By doing this I am trying to capture the workflow failure details, But I am getting this as output,
When I try to expand this I get this, and you can see after the pod name it went to next line.
If you see the format is only wrong. I want to send this data to a notification channel, But I am getting the error as invalid json format. I guess this is issue from argocd. If not please tell me how to do it? @alexec
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions