A job in Rundeck is being executed through a shell script using curl but the response I get is just the output of the HTTP Request made by curl.
How do I get the Rundeck job log output to show after running the script with curl?
Hi Tim,
It’s possible in two steps: the first one running the job, taking the execution ID via JQ, and then, printing the output of that execution id through this endpoint.
I tested with this script example:
# store the exec id on a variable
my_exec=$(curl -s -X POST 'http://localhost:4440/api/41/job/1a5b1774-2c03-4313-b6fb-f66d0a96f7fb/run' --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: h8HWwRSojZ0Ip2it2jLJDZ80FmktDUNF' | jq -r '.id')
# few seconds until the end of the execution
sleep 5
# and then print the output (entries section)
curl -s -X GET "http://localhost:4440/api/41/execution/$my_exec/output" --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: h8HWwRSojZ0Ip2it2jLJDZ80FmktDUNF'
Hope it helps!
Hi Tim,
Using grep + awk it’s possible:
my_exec=$( curl -s -X POST 'http://localhost:4440/api/41/job/d56c8c43-de29-4b17-8a0c-3cab8728df55/run' --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: k5k80EqvrPgieRQXz2Pa2JHcT5SLZ2yh' | grep -o -E "\"id\":[0-9]+" | awk -F\: '{print $2}' )
sleep 5
curl -s -X GET "http://localhost:4440/api/41/execution/$my_exec/output" --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: k5k80EqvrPgieRQXz2Pa2JHcT5SLZ2yh'
Greetings!
PD: I deleted the last post due to “formatting” issues.