From d63391d00b9705879d74040108a6e1a00e6739a6 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Thu, 26 Jan 2017 06:27:17 +0100 Subject: [PATCH] Improve wheels uploading script to detect error conditions (closes #37) --- gitlab/functions.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gitlab/functions.sh b/gitlab/functions.sh index d2f2a42..6e8dcde 100644 --- a/gitlab/functions.sh +++ b/gitlab/functions.sh @@ -161,15 +161,18 @@ setup_deploy() { # Uploads a file to our intranet location via curl +# $1: Path to the file to upload (e.g. dist/myfile.whl) +# $2: Path on the server to upload to (e.g. wheels-upload/gitlab/) doc_upload() { log_info "curl: ${1} -> ${DOCSERVER}/${2}..." - curl --location --silent --show-error --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2} - local status=$? - if [ ${status} != 0 ]; then - log_error "Curl command finished with an error condition (status=${status})" + local code=`curl --location --silent --fail --write-out "%{http_code}" --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2}` + if [[ ${code} == 204 || ${code} == 201 ]]; then + log_info "Successfully uploaded ${1} with curl" + else + log_error "Curl command finished with an error condition (code=${code}):" + curl --location --silent --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2} exit ${status} fi - log_info "Successfully uploaded ${1} with curl" } -- GitLab