From e23a5f736d87c189a9ee80baae2e1edccba1441d Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 3 Mar 2016 13:04:11 -0500 Subject: [PATCH] Some start/stop fedmsg messages wrapped around nightly.sh. As well as fedmsg notify on rsync start/stop. Signed-off-by: Ralph Bean --- fedmsg-functions.sh | 36 ++++++++++++++++++++++++++++++++++++ nightly.sh | 19 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 fedmsg-functions.sh diff --git a/fedmsg-functions.sh b/fedmsg-functions.sh new file mode 100644 index 0000000..e3d4b03 --- /dev/null +++ b/fedmsg-functions.sh @@ -0,0 +1,36 @@ +# fedmsg-functions +# +# This is a bash shell script that is meant to be sourced by other scripts +# and aims to deliver functions common to sending messages to fedmsg[0] +# in rel-eng shell scripts. +# +# [0] - http://www.fedmsg.com/en/latest/ + + +# NOTES: +# - Scripts that source this should define at least the following: +# FEDMSG_MODNAME +# FEDMSG_CERTPREFIX +# +# Example: +# +# FEDMSG_MODNAME="compose" +# FEDMSG_CERTPREFIX="bodhi" +# source ./scripts/fedmsg-functions.sh +# +# fedmsg_json_start=$(printf '{"log": "start", "branch": "f24", "arch": "x86_64"}') +# send_fedmsg "${fedmsg_json_start}" f24 start + +function send_fedmsg() +{ + jsoninput="${1}" + dist="${2}" + topic="${3}" + + echo ${jsoninput} | fedmsg-logger \ + --cert-prefix ${FEDMSG_CERTPREFIX} \ + --modname ${FEDMSG_MODNAME} \ + --topic "${dist}.${topic}" \ + --json-input +} + diff --git a/nightly.sh b/nightly.sh index 4d6e8c9..19ff497 100755 --- a/nightly.sh +++ b/nightly.sh @@ -27,6 +27,16 @@ OLDCOMPOSE_ID=$(cat $TARGET_DIR/latest-Fedora-/COMPOSE_ID) # uncomment and edit for resuming a failed compose #COMPOSE_ID="Fedora-23-20150530.n.0" +# Set up our fedmsg function +fedmsg_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s"}' "$BRANCHED" "$ARCH") +fedmsg_json_done=$(printf '{"log": "done", "branch": "%s", "arch": "%s"}' "$BRANCHED" "$ARCH") +FEDMSG_MODNAME="compose" +FEDMSG_CERTPREFIX="releng" +. ./fedmsg-functions.sh + +# Announce that we are starting... +send_fedmsg "${fedmsg_json_start}" ${DIST} start + # assume a releng dir is a git checkout of teh releng repo # if it does not exist clone it if [ -d releng ]; then @@ -100,6 +110,8 @@ compose-changelog -p $TARGET_DIR/$NEWCOMPOSE_ID/logs/ $TARGET_DIR/$OLDCOMPOSE_ID ./releng/scripts/critpath.py --url file://$DESTDIR/compose/Everything -o $DESTDIR/logs/critpath.txt branched &> $DESTDIR/logs/critpath.log } +# Tell interested persons that the rsync is starting (zomg!) +send_fedmsg "${fedmsg_json_start}" ${DIST} rsync.start for dir in Everything Atomic CloudImages Docker Server Spins Workstation ; do @@ -113,6 +125,13 @@ for dir in Cloud Labs ; $RSYNCPREFIX rsync -avhH $TARGET_DIR/$NEWCOMPOSE_ID/compose/$dir/ /pub/alt/development/$DIST/$dir/ --link-dest=/pub/fedora/linux/development/$DIST/Everything/ --delete-after ; done +# Tell interested persons that the rsync is done. +send_fedmsg "${fedmsg_json_done}" ${DIST} rsync.complete + +# Tell everyone by fedmsg about the compose +send_fedmsg "${fedmsg_json_done}" ${DIST} complete + +# Tell everyone by email about the compose SUBJECT='Fedora '$DIST' compose report: '$SHORTCOMPOSE_ID' changes' if [ "$mail" = "0" ]; then for tomail in $TOMAIL ; do