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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With