Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to execute a Curl script on Jenkins so as to check the status URL

The script should check for Http status code for the URL and should show error when status code doesn't match for eg. 200. In Jenkins if this script fails then Build should get failed and Mail is triggered through post build Procedure.

like image 853
Kworks Avatar asked Jan 21 '14 05:01

Kworks


1 Answers

Another interesting feature of curl is its -f/--fail option. If set, it will tell curl to fail on any HTTP error, i.e. curl will have an exit code different from 0, if the server response status code was not 1xx/2xx/3xx, i.e. if it was 4xx or above, so

curl --silent --fail "http://www.example.org/" >/dev/null

or (equivalently):

curl -sf "http://www.example.org/" >/dev/null

would have an exit code of 22 rather than 0, if the URL could not be found or if some other HTTP error occurred. See man curl for a description of curl's various exit codes.

like image 61
Robin479 Avatar answered Nov 15 '22 07:11

Robin479