linux - Docker - How to check if curl command inside Dockerfile had response code 200 -
inside dockerfile try download artifact using curl. have checked although artifact doesn't exist (thus getting 404) docker build keeps running.
run curl -h 'cache-control: no-cache' ${standalone_location} -o $jboss_home/standalone/configuration/standalone.xml
is there way check curl response code 200 , throw error otherwise?
you can add -f
(or --fail
) curl call, causes curl silently fail on server errors. curl manpage:
-f/--fail
(http) fail silently (no output @ all) on server errors. done better enable scripts etc better deal failed attempts. in normal cases when http server fails deliver document, returns html document stating (which describes why , more). flag prevent curl outputting , return error 22.
this method not fail-safe , there occasions non-successful response codes slip through, when authentication involved (response codes 401 , 407).
Comments
Post a Comment