summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2014-11-03 12:00:53 +0100
committerHolger Levsen <holger@layer-acht.org>2014-11-03 12:00:53 +0100
commitd03ffcfd3466873611a85064896e49817697ba30 (patch)
treec61a26358da388fc2e8b0ac340638b241e9c6948 /bin
parent44d81b23b6b7d785673cb8a0e7a23b31b2c8a4a2 (diff)
downloadjenkins.debian.net-d03ffcfd3466873611a85064896e49817697ba30.tar.xz
email2irc: refactor
Diffstat (limited to 'bin')
-rwxr-xr-xbin/email2irc.sh28
1 files changed, 19 insertions, 9 deletions
diff --git a/bin/email2irc.sh b/bin/email2irc.sh
index 8633dd0f..dd02f39d 100755
--- a/bin/email2irc.sh
+++ b/bin/email2irc.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright 2012 Holger Levsen <holger@layer-acht.org>
+# Copyright 2012-2014 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
#
@@ -8,7 +8,14 @@
# to turn jenkins email notifications into irc announcements with kgb
# see http://kgb.alioth.debian.org/
#
-LOGFILE=/var/lib/jenkins/email_log
+LOGFILE=/var/log/jenkins/email.log
+# FIXME: add logrotate rule for /var/log/jenkins/email.log
+
+debug123() {
+ if $DEBUG ; then
+ echo "Debug: $1 $2 $3" >> $LOGFILE
+ fi
+}
#
# parse email headers to check if they come from jenkins
@@ -47,25 +54,28 @@ while read line ; do
JENKINS_JOB=${line:15}
fi
fi
+ DEBUG=true
# catch first line of email body (to send to IRC later)
if [ "$HEADER" == "false" ] && [ -z "$MY_LINE" ] ; then
MY_LINE=$line
+ debug123 "#1" MY_LINE $MY_LINE
# if this is a multipart email it comes from the email extension plugin
- if [ "${line:0:5}" = "-----" ] ; then
- read line
- read line
- read line
- MY_LINE=$(echo $line | cut -d " " -f1-2)
+ if [ "${line:0:7}" = "------=" ] ; then
+ debug123 "#2" line $line
+ MY_LINE=""
else
- MY_LINE=$(echo $line | tr -d \< | tr -d \>)
+ debug123 "#3" line $line
+ MY_LINE=$(echo $line | tr -d \< | tr -d \> | cut -d " " -f1-2)
+ debug123 "#4" MY_LINE $MY_LINE
fi
fi
-
+ DEBUG=false
done
# check that it's a valid job
if [ -z $JENKINS_JOB ] ; then
VALID_MAIL=false
fi
+debug123 "#5" MY_LINE $MY_LINE
# only send notifications for valid emails
if [ "$VALID_MAIL" == "true" ] ; then