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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -