fix: make curl fail fast on HTTP error

This commit is contained in:
2024-10-05 11:08:26 +02:00
parent 6331646181
commit c4b4b66692
+16 -10
View File
@@ -70,13 +70,19 @@ handle_mr:
--arg content "${CONTENT}" \
--arg startBranch "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}")"
curl -s -X PUT \
# Check if CHANGELOG.md exists
if curl -sf --head \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd"
if [ $? -ne 0 ]; then
curl -s -X POST \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd?ref=next-release"; then
# Exists => update
curl -sf -X PUT \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd"
else
# Not exists => create
curl -sf -X POST \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \
@@ -85,7 +91,7 @@ handle_mr:
if [ -n "${MR}" ]; then
echo "Updating existing MR"
echo "Rebasing branch"
curl -s -X PUT \
curl -sf -X PUT \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}/rebase"
@@ -95,7 +101,7 @@ handle_mr:
--arg title "${TITLE}" \
--arg target "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}")
curl -s -X PUT \
curl -sf -X PUT \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \
@@ -107,7 +113,7 @@ handle_mr:
--arg title "${TITLE}" \
--arg target "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}")
curl -s -X POST \
curl -sf -X POST \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \
@@ -162,7 +168,7 @@ release:
--arg message "${MESSAGE}" \
--arg ref "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}")"
curl -s -X POST \
curl -sf -X POST \
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
--data "${BODY}" \