Added reporting
[invirt/packages/invirt-dev.git] / build-hooks / failed-submit
1 #!/bin/sh
2
3 set -e
4 set -u
5
6 escape() {
7     echo "$1" | sed -e 's/@/@@/g'
8 }
9
10 pocket=$(escape "$1")
11 package=$(escape "$2")
12 commit=$(escape "$3")
13 principal=$(escape "$4")
14
15 base=build.hooks.failed_submit.zephyr
16 class=$(invirt-getconf "$base.class" 2>/dev/null || :)
17 instance=$(invirt-getconf "$base.instance" 2>/dev/null || :)
18 zsig=$(invirt-getconf "$base.zsig" 2>/dev/null || :)
19
20 if [ -z "$class" ]; then
21   echo "I don't know where to send a commit zephyr!" >&2
22   echo "Please provide a value for $base.class in" >&2
23   echo "your invirt config file." >&2
24   exit 1
25 fi
26
27 (echo "A new job has @{@color(red)failed} to be submitted to the Invirtibuilder:"
28  echo
29  echo "pocket: $pocket"
30  echo "package: $package"
31  echo "commit: $commit"k
32  echo "principal: $principal"
33  echo
34  echo -n "Failure: ";
35  ( cat | sed -e 's/@/@@/g' ) ) | zwrite -c "$class" -i "${instance:-$commit}" -s "${zsig:-failed-submit}: $pocket" -d