déplacement depuis dépôt con...
|
1 |
#!/bin/bash |
2 | ||
3 |
source_path=${1:-"$HOME/scripts/flightgear/source"} |
|
4 |
job=fgfs |
|
5 | ||
6 |
function xmlgetnext () { |
|
7 |
local IFS='>' |
|
8 |
read -d '<' TAG VALUE |
|
9 |
# by design, the first TAG/VALUE pair is empty |
|
10 |
# to avoid infinite loops at end of file parsing we return an error |
|
11 |
# the next time we find an empty TAG |
|
12 |
if test -z "$TAG"; then |
|
13 |
test ${xmlgetnext_firstentry:-1} -eq 1 && xmlgetnext_firstentry=0 || return 1; |
|
14 |
fi |
|
15 |
# process $TAG only if necessary |
|
16 |
local _TAG=$(printf '%q' $TAG) |
|
17 |
if test ${_TAG:0:1} = '$'; then |
|
18 |
TAG=$(tr '\n' ' ' <<< $TAG | sed 's/ */ /g; s/ *$//') |
|
19 |
fi |
|
20 |
} |
|
21 | ||
22 |
exit_trap () { |
|
23 |
rm $apixml |
|
24 |
} |
|
25 | ||
26 |
set -e |
|
27 |
trap exit_trap EXIT |
|
28 | ||
29 |
apixml=$(mktemp --dry-run /dev/shm/XXXXXXXXXX) |
|
30 | ||
31 |
wget -qO- --header 'Accept:application/xml' http://build.flightgear.org:8080/job/$job/api/xml > $apixml |
|
32 | ||
33 |
declare -A code |
|
34 | ||
35 |
while xmlgetnext; do |
|
36 |
case "${TAG:0:1}" in |
|
37 |
''|'?'|'!') |
|
38 |
continue;; |
|
39 |
/) |
|
40 |
property=${property%/*};; |
|
41 |
*) |
|
42 |
if test "${TAG: -1}" != '/'; then |
|
43 |
property+=/${TAG%% *} |
|
44 |
fi;; |
|
45 |
esac |
|
46 | ||
47 |
case "$property" in |
|
48 |
/workflowJob/healthReport/score) |
|
49 |
score=$VALUE;; |
|
50 | ||
51 |
/workflowJob/lastSuccessfulBuild/url) |
|
52 |
wget -qO- --header 'Accept:application/xml' ${VALUE}/api/xml >> $apixml;; |
|
53 | ||
54 |
/workflowRun/action/lastBuiltRevision/branch/SHA1) |
|
55 |
sha1=$VALUE;; |
|
56 | ||
57 |
/workflowRun/action/remoteUrl) |
|
58 |
[[ ${VALUE##*/} = @(flight|sim)gear ]] && code[${VALUE##*/}]=$sha1;; |
|
59 | ||
60 |
/workflowRun/result) |
|
61 |
result=$VALUE |
|
62 |
for path in ${!code[@]}; do |
|
63 |
if test $(git -C "$source_path/$path" rev-parse HEAD) != ${code[$path]}; then |
|
64 |
echo "mismatch revision from jenkins info" |
|
65 |
exit |
|
66 |
fi |
|
67 |
done |
|
68 |
echo "result: $result, score $score" |
|
69 |
exit;; |
|
70 |
esac |
|
71 |
done < $apixml |