summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2014-10-30 01:01:58 +0100
committerHolger Levsen <holger@layer-acht.org>2014-10-30 01:01:58 +0100
commit70b2b809f29f8bf674b32147a449e79a42a81f41 (patch)
treea85375df406904b2e05b547d3ae4cb93ee90145a /bin
parentab7d0f09f68a4b7e901d2de1d45d71e8f6341d08 (diff)
downloadjenkins.debian.net-70b2b809f29f8bf674b32147a449e79a42a81f41.tar.xz
email2irc: deal with multipart-messages from Extended Email Plugin
Diffstat (limited to 'bin')
-rwxr-xr-xbin/email2irc.sh22
1 files changed, 14 insertions, 8 deletions
diff --git a/bin/email2irc.sh b/bin/email2irc.sh
index 1c8b38de..472616c4 100755
--- a/bin/email2irc.sh
+++ b/bin/email2irc.sh
@@ -15,7 +15,7 @@ LOGFILE=/var/lib/jenkins/email_log
#
HEADER=true
VALID_MAIL=false
-FIRST_LINE=""
+MY_LINE=""
while read line ; do
if [ "$HEADER" == "true" ] ; then
# check if email header ends
@@ -43,8 +43,16 @@ while read line ; do
fi
fi
# catch first line of email body (to send to IRC later)
- if [ "$HEADER" == "false" ] && [ -z "$FIRST_LINE" ] ; then
- FIRST_LINE=$line
+ if [ "$HEADER" == "false" ] && [ -z "$MY_LINE" ] ; then
+ MY_LINE=$line
+ # if this is a multipart email it comes from the email extension plugin
+ if [ "${line:0:5}" = "-----" ] ; then
+ read line
+ read line
+ MY_LINE=$(read line | cut -d " " -f1-2)
+ else
+ MY_LINE=$(echo $line | tr -d \< | tr -d \>)
+ fi
fi
done
@@ -57,15 +65,13 @@ fi
if [ "$VALID_MAIL" == "true" ] ; then
echo -e "----------\nvalid email\n-----------" >> $LOGFILE
echo $JENKINS_JOB | cut -d ":" -f1 >> $LOGFILE
- SUBJECT=$(echo $SUBJECT | cut -d ":" -f1)
echo $SUBJECT >> $LOGFILE
- echo $FIRST_LINE >> $LOGFILE
+ echo $MY_LINE >> $LOGFILE
# only notify if there is a channel to notify
if [ ! -z $CHANNEL ] ; then
# log message
- echo "#$CHANNEL: $SUBJECT. $FIRST_LINE" >> $LOGFILE
- #MESSAGE=$(echo "$SUBJECT. $FIRST_LINE" | colorit -c /etc/colorit.conf )
- MESSAGE="$JENKINS_JOB: $SUBJECT. $FIRST_LINE"
+ echo "#$CHANNEL: $SUBJECT. $MY_LINE" >> $LOGFILE
+ MESSAGE="$JENKINS_JOB: $SUBJECT. $MY_LINE"
# notify kgb
kgb-client --conf /srv/jenkins/kgb/$CHANNEL.conf --relay-msg "$MESSAGE" && echo "kgb informed successfully." >> $LOGFILE
echo >> $LOGFILE