aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-hydra-status.sh
blob: c1d2d7c406e6a1298bc29668eaa87e1456878144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

set -euo pipefail
# set -x


# mapfile BUILDS_FOR_LATEST_EVAL < <(
# curl -H 'Accept: application/json' https://hydra.nixos.org/jobset/nix/master/evals | \
#   jq -r '.evals[0].builds[] | @sh')
BUILDS_FOR_LATEST_EVAL=$(
curl -sS -H 'Accept: application/json' https://hydra.nixos.org/jobset/nix/master/evals | \
  jq -r '.evals[0].builds[]')

someBuildFailed=0

for buildId in $BUILDS_FOR_LATEST_EVAL; do
  buildInfo=$(curl -sS -H 'Accept: application/json' "https://hydra.nixos.org/build/$buildId")

  buildStatus=$(echo "$buildInfo" | \
    jq -r '.buildstatus')

  if [[ "$buildStatus" -ne 0 ]]; then
    someBuildFailed=1
    echo "Job “$(echo "$buildInfo" | jq -r '.job')” failed on hydra"
  fi
done

exit "$someBuildFailed"