diff options
author | Holger Levsen <holger@layer-acht.org> | 2012-11-20 00:27:19 +0100 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2012-11-20 00:27:19 +0100 |
commit | fd972c12328219914e56a931c0e570df41744082 (patch) | |
tree | ae305c8524b5f60c0699017712302c955d9f5d4c /bin | |
parent | 5deb7ac323b97755d1a3d85a87d0985f8d022c2a (diff) | |
download | jenkins.debian.net-fd972c12328219914e56a931c0e570df41744082.tar.xz |
enable irc notification kgb-bot and jenkins email plugin
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/email2irc.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/bin/email2irc.sh b/bin/email2irc.sh new file mode 100755 index 00000000..60382a3c --- /dev/null +++ b/bin/email2irc.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# +# FIXME: this needs cleanup soo much +# + +HEADER=true +VALID_MAIL=false +FIRST_LINE="" +while read line ; do + if [ "$HEADER" == "true" ] ; then + if [[ $line =~ ^$ ]] ; then + HEADER=false + fi + if [[ $line =~ ^(From: jenkins@jenkins.debian.net) ]] ; then + VALID_MAIL=true + fi + if [[ $line =~ ^(Subject: .*) ]] ; then + SUBJECT=${line:9} + fi + if [[ $line =~ ^(To: .*) ]] ; then + echo $line >> /var/lib/jenkins/email_log + CHANNEL=$(echo $line | cut -d "+" -f2| cut -d "@" -f1) + echo "CHANNEL = $CHANNEL" >> /var/lib/jenkins/email_log + echo >> /var/lib/jenkins/email_log + fi + if [[ $line =~ ^(X-Jenkins-Job: .*) ]] ; then + JENKINS_JOB=${line:15} + fi + fi + if [ "$HEADER" == "false" ] && [ -z "$FIRST_LINE" ] ; then + FIRST_LINE=$line + fi + +done +if [ -z $JENKINS_JOB ] ; then + VALID_MAIL=false +fi + +if [ "$VALID_MAIL" == "true" ] ; then + echo -e "----------\nvalid email\n-----------" >> /var/lib/jenkins/email_log + echo $JENKINS_JOB | cut -d ":" -f1 >> /var/lib/jenkins/email_log + SUBJECT=$(echo $SUBJECT | cut -d ":" -f1) + echo $SUBJECT >> /var/lib/jenkins/email_log + echo $FIRST_LINE >> /var/lib/jenkins/email_log + if [ ! -z $CHANNEL ] ; then + echo "#$CHANNEL: $SUBJECT. $FIRST_LINE" >> /var/lib/jenkins/email_log + kgb-client --conf /srv/jenkins/kgb/$CHANNEL.conf --relay-msg "$SUBJECT. $FIRST_LINE" + else + echo "But no irc channel detected." >> /var/lib/jenkins/email_log + fi +else + echo -e "----------\nbad luck\n-----------" >> /var/lib/jenkins/email_log +fi + + |