Reputation: 3278
I have jenkins build console output of a job that i want to use in execute shell of the same job. The output is
POST Response Code: 200
Response:
{"status":"success","results":{"job_id":"57","ip":null,"hostname":null}}
I want to use the status variable to print whether is is success or failure. How can I do that.
Im using echo "$status" its not working
Upvotes: 0
Views: 207
Reputation: 11030
I think you want to break the job based on the value right?
You can sed the response:
echo '{"status":"success","results":{"job_id":"57","ip":null,"hostname":null}}'
\ | sed -r 's|.+status":"(.+?)","r.*|\1|p'
Assign it to a variable and do whatever you want.
Otherwise you can use the Text-finder Plugin. You assign the response of your action to a temporary file and let the plugin check for a phrase.
Upvotes: 1