navid/veins / master / .buildkite/scripts/report-status.sh

report-status.sh

← .buildkite/scripts · 785 bytes · raw · download

#!/usr/bin/env bash
set -euo pipefail

state="${1:?usage: report-status.sh <state>}"

if [ -z "${VEINSFORGE_CI_TOKEN:-}" ]; then
    exit 0
fi

commit="${VEINSFORGE_COMMIT:-${BUILDKITE_COMMIT:-}}"
if [ -z "$commit" ]; then
    echo "no Veins commit available for CI status" >&2
    exit 0
fi

base="${VEINSFORGE_BASE_URL:-https://veinsforge.top}"
context="${VEINSFORGE_CI_CONTEXT:-buildkite}"

body="$(jq -n \
    --arg commit "$commit" \
    --arg state "$state" \
    --arg context "$context" \
    --arg url "${BUILDKITE_BUILD_URL:-}" \
    '{commit: $commit, state: $state, context: $context, url: $url}')"

curl -fsS -X POST "${base%/}/api/v1/ci/status" \
    -H "Authorization: Bearer ${VEINSFORGE_CI_TOKEN}" \
    -H "Content-Type: application/json" \
    -d "$body" >/dev/null