Skip to content

Commit

Permalink
Catch curl uploading error when upload fails
Browse files Browse the repository at this point in the history
Also corrects conditions of number comparions.

Signed-off-by: Sunnatillo <sunnat.samadov@est.tech>
  • Loading branch information
Sunnatillo committed Nov 5, 2024
1 parent 8103e5a commit df41296
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jenkins/image_building/upload-node-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rt_delete_artifact() {
rt_upload_artifact() {
local src_path="${1:?}"
local dst_path="${2:?}"
curl -s -XPUT -u"${RT_USER:?}:${RT_TOKEN:?}" "${RT_URL}/${dst_path}" -T "${src_path}"
curl -s --fail-with-body -XPUT -u"${RT_USER:?}:${RT_TOKEN:?}" "${RT_URL}/${dst_path}" -T "${src_path}"
}

rt_list_directory() {
Expand Down
11 changes: 6 additions & 5 deletions jenkins/scripts/artifactory/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ rt_upload_artifact() {
ANONYMOUS="${3:-1}"

_CMD="curl \
$( ([[ "${ANONYMOUS}" != 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
--fail-with-body \
$( ([[ ""${ANONYMOUS}" -ne 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
${RT_URL}/${DST_PATH} \
-T ${SRC_PATH}"
Expand All @@ -46,7 +47,7 @@ rt_download_artifact() {
ANONYMOUS="${3:-1}"
_CMD="curl -s \
$( ([[ "${ANONYMOUS}" != 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
$( ([[ ""${ANONYMOUS}" -ne 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
-XGET \
${RT_URL}/${SRC_PATH} \
-o ${DST_PATH}"
Expand All @@ -71,7 +72,7 @@ rt_cat_artifact() {
ANONYMOUS="${2:-1}"
_CMD="curl -s \
$( ([[ "${ANONYMOUS}" != 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
$( ([[ ""${ANONYMOUS}" -ne 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
-XGET \
${RT_URL}/${SRC_PATH}"
Expand All @@ -95,7 +96,7 @@ rt_delete_artifact() {
ANONYMOUS="${2:-1}"
_CMD="curl -s \
$( ([[ "${ANONYMOUS}" != 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
$( ([[ ""${ANONYMOUS}" -ne 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
-XDELETE \
${RT_URL}/${DST_PATH}"
Expand All @@ -120,7 +121,7 @@ rt_list_directory() {
ANONYMOUS="${2:-1}"
_CMD="curl -s \
$( ([[ "${ANONYMOUS}" != 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
$( ([[ ""${ANONYMOUS}" -ne 1 ]] && echo " -u${RT_USER:?}:${RT_TOKEN:?}") || true) \
-XGET \
${RT_URL}/api/storage/${DST_PATH}"
Expand Down

0 comments on commit df41296

Please sign in to comment.