[CI] Read the CRCR report token from a Buildkite secret (#54605)
Signed-off-by: Andrey Talman <atalman@fb.com>
This commit is contained in:
@@ -37,9 +37,16 @@ fi
|
||||
|
||||
# read_builds only. Needed because a job cannot see its siblings' outcomes:
|
||||
# the agent exposes only its own step, so the job list comes from the REST API.
|
||||
TOKEN_SECRET_KEY="${CRCR_BUILDKITE_TOKEN_SECRET_KEY:-CRCR_BUILDKITE_API_TOKEN}"
|
||||
BK_TOKEN="${BUILDKITE_API_TOKEN:-}"
|
||||
if [[ -z "${BK_TOKEN}" ]] && command -v buildkite-agent >/dev/null 2>&1; then
|
||||
# Not in the job environment, so read it from a Buildkite secret. The agent
|
||||
# redacts values fetched this way from the log.
|
||||
BK_TOKEN="$(buildkite-agent secret get "${TOKEN_SECRET_KEY}" 2>/dev/null)" || BK_TOKEN=""
|
||||
fi
|
||||
if [[ -z "${BK_TOKEN}" ]]; then
|
||||
echo "BUILDKITE_API_TOKEN unset -- skipping report"
|
||||
echo "no Buildkite API token (env BUILDKITE_API_TOKEN or secret" \
|
||||
"'${TOKEN_SECRET_KEY}') -- skipping report"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user