# HG changeset patch
# User Steeve Chailloux <steeve.chailloux@orus.io>
# Date 1654187387 -7200
#      Thu Jun 02 18:29:47 2022 +0200
# Node ID 2ebef29aa8a77a594a37a2336786ca05e1f93c0a
# Parent  6aeaa5d9c326235a6b25d1aa9be27086162a3516
raise an error on upload fail

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -58,4 +58,11 @@
       - build
   script:
     - apk add curl
-    - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file build/beaver "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/beaver/latest/beaver"'
+    - |
+      OUTPUT_FILE=$(mktemp)
+      HTTP_CODE=$(curl --silent --output $OUTPUT_FILE --write-out "%{http_code}" --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file build/beaver "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/beaver/latest/beaver")
+      echo "return $HTTP_CODE"
+      cat $OUTPUT_FILE
+      if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
+        exit 1
+      fi