Avatar of saharey
saharey

asked on 

Grep command for REST API Jenkins job not working

Below shell script is issue for grep, can anyone help me out in this, trying to grep string from Jenkins job status but it is not working, job_status variable is getting assigned blank value.
JENKINS_SERVER=http://umount-altmount:8090
JOB_NAME=get_shelved_job

job_status=`curl http://${JENKINS_SERVER}/job/${JOB_NAME}/lastBuild/api/json | grep "\"result\":\"SUCCESS\""`

if [ -n "$job_status" ]
then
    # Run your script commands here
    echo "Build Sucess"
else
  echo "BUILD FAILURE: Other build is unsuccessful or status could not be obtained."
  exit 1
fi

Open in new window

Shell ScriptingLinux

Avatar of undefined
Last Comment
saharey

8/22/2022 - Mon