Make curl fail on error

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2022-12-06 20:03:16 +00:00
parent 2085ad6945
commit 7e42ba6ecc
2 changed files with 4 additions and 4 deletions

View file

@ -20,7 +20,7 @@ fi
function call() { function call() {
PAYLOAD="$1" PAYLOAD="$1"
curl -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)" curl --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)"
} }
function sendStatus() { function sendStatus() {
@ -41,7 +41,7 @@ function fail() {
} }
sendStatus "downloading tools from ${DOWNLOAD_URL}" sendStatus "downloading tools from ${DOWNLOAD_URL}"
curl -L -H "${TEMP_TOKEN}" -o "/home/runner/${FILENAME}" "${DOWNLOAD_URL}" || fail "failed to download tools" curl --fail -L -H "${TEMP_TOKEN}" -o "/home/runner/${FILENAME}" "${DOWNLOAD_URL}" || fail "failed to download tools"
mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder" mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder"

View file

@ -20,7 +20,7 @@ fi
function call() { function call() {
PAYLOAD="$1" PAYLOAD="$1"
curl -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)" curl --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)"
} }
function sendStatus() { function sendStatus() {
@ -41,7 +41,7 @@ function fail() {
} }
sendStatus "downloading tools from ${DOWNLOAD_URL}" sendStatus "downloading tools from ${DOWNLOAD_URL}"
curl -L -H "${TEMP_TOKEN}" -o "/home/runner/${FILENAME}" "${DOWNLOAD_URL}" || fail "failed to download tools" curl --fail -L -H "${TEMP_TOKEN}" -o "/home/runner/${FILENAME}" "${DOWNLOAD_URL}" || fail "failed to download tools"
mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder" mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder"