-
Notifications
You must be signed in to change notification settings - Fork 6
/
gerrit-stream
executable file
·32 lines (30 loc) · 1.27 KB
/
gerrit-stream
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
29
30
31
#!/usr/bin/env bash
source ${CI}/config
echo "Connecting to review.openstack.org.."
ssh -p 29418 review.openstack.org gerrit stream-events |
(while read -r line; do
uuid=$(uuidgen)
stamp=$(date "+%F %T")
event=$(mktemp)
chmod a+r ${event} # mktemp sets user-only
printf "%s" ${line} | python -mjson.tool > ${event}
if [ $# != 0 ]; then
echo "${stamp} ${uuid} got malformed event."
fi
project=$(cat ${event} | sed -z -e 's/.*"project": "//' -e 's/".*//')
url=$(cat ${event} | sed -z -e 's/.*"url": "//' -e 's/".*//')
date=$(date "+%F")
# Filter for relevance
if [ "${CI_PROMISC}" == "yes" ] ||
(grep -q -e "^ *\"project\": \"${CI_PROJECT?}" ${event} &&
grep -q -e "^ *\"comment\": \"recheck \(no \)* bug" \
-e "^ *\"type\": \"patchset-created\"" ${event}); then
[ -d ${CI}/tests/${date} ] || mkdir -p ${CI}/tests/${date}
cp -r ${CI_TEST_CASE?} ${CI}/tests/${date}/${uuid}
mv ${event} ${CI}/tests/${date}/${uuid}/event.json
echo "${stamp} ${uuid} EVENT ${url}" | tee -a ${CI?}/log/activity.log
else
rm ${event}
echo "${stamp} ${uuid} no test needed for event - project=${project} url=${url}"
fi
done)