diff --git a/.gitlab/gen-badge.sh b/.gitlab/gen-badge.sh index f02d9c4dee1b79b2c295ec45e3ba35841dc8d2c8..8d4290b83d8a678e5ff8fa6efda13eb056dd3ee6 100644 --- a/.gitlab/gen-badge.sh +++ b/.gitlab/gen-badge.sh @@ -1,5 +1,9 @@ #!/bin/bash GITLAB_URL="https://gitlab.phaidra.org" -RAW=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/latest?ref=${CI_COMMIT_BRANCH}") -anybadge --label pipeline --value "$(echo ${RAW} | jq --raw-output .detailed_status.text)" failed=red passed=green canceled=darkgray > /tmp/pipeline.svg -anybadge --label pipeline --value "$(echo ${RAW} | jq --raw-output .coverage)" 70=red 80=orange 90=yellow 95=green > /tmp/coverage.svg \ No newline at end of file +PIPELINE_STATUS=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/latest?ref=${CI_COMMIT_BRANCH}" | jq --raw-output .detailed_status.text) +anybadge --label pipeline --value "${PIPELINE_STATUS}" failed=red passed=green canceled=darkgray > /tmp/pipeline.svg +PIPELINE_COVERAGE=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/latest?ref=${CI_COMMIT_BRANCH}" | jq --raw-output .coverage) +if [ "${PIPELINE_COVERAGE}" == "null" ]; then + PIPELINE_COVERAGE="unknown" +fi +anybadge --label pipeline --value "${PIPELINE_COVERAGE}" unknown=darkgray 70=red 80=orange 90=yellow 95=green > /tmp/coverage.svg