diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cfa29d080cc5dc2e02e0649e55b0d2710b7bb7a6..50977820552c0d04583fa8a7df7c46ad2cdce6d8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -441,7 +441,7 @@ release-docs:
     - "cp .docs/.swagger/custom.css ./final/${APP_VERSION}/rest/custom.css" # swagger
     - "cp -r ./site/* ./final/${APP_VERSION}" # mkdocs
     - "cp .docker/dist.tar.gz ./final/${APP_VERSION}/dist.tar.gz" # dist
-    - "anybadge --label pipeline --value \"$(curl -fsSL -H 'PRIVATE-TOKEN: ${CI_TOKEN}' 'https://gitlab.phaidra.org/api/v4/projects/450/pipelines?ref=${CI_COMMIT_BRANCH}' | jq '[.[]|select(.)][0].status')\" failed=red success=green > /tmp/pipeline.svg"
+    - "bash ./.gitlab/gen-badge.sh"
     - "cp /tmp/pipeline.svg ./final/${APP_VERSION}/images/pipeline.svg" # badges
     - eval $(ssh-agent -s)
     - "mkdir -p /root/.ssh"
diff --git a/.gitlab/gen-badge.sh b/.gitlab/gen-badge.sh
new file mode 100644
index 0000000000000000000000000000000000000000..a74f59d6c2bf546f65699bdf6358580493c7943b
--- /dev/null
+++ b/.gitlab/gen-badge.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+GITLAB_URL="https://gitlab.phaidra.org"
+PIPELINE_ID=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines?ref=${CI_COMMIT_BRANCH}" | jq '[.[]|select(.)][0].id')
+echo "[INFO] pipeline id: ${PIPELINE_ID}"
+STATUS_RAW=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/${PIPELINE_ID}" | jq '.detailed_status')
+echo "[DEBUG] response: ${STATUS_RAW}"
+anybadge --label pipeline --value "$(echo ${STATUS_RAW} | jq --raw-output .text)" failed=red passed=green canceled=darkgray > /tmp/pipeline.svg
\ No newline at end of file