Skip to content

Instantly share code, notes, and snippets.

@fclairamb
Created October 9, 2015 10:02
Show Gist options
  • Save fclairamb/901d2f04a535a98430db to your computer and use it in GitHub Desktop.
Save fclairamb/901d2f04a535a98430db to your computer and use it in GitHub Desktop.
Jenkins SVN changes notifications (when your sysadmins don't want to add a post-commit hook to the SVN repository)
[ -f /usr/bin/svn ] || sudo apt-get install subversion -y
[ -f /usr/bin/mail ] || sudo apt-get install mailutils -y
[ -f /usr/bin/pip ] || sudo apt-get install python-pip -y
sudo pip install pygments >/dev/null
SVN_NEW=$SVN_REVISION_1
SVN_OLD=$(cat svn_old ||:)
echo $SVN_NEW >svn_old
svn log $SVN_URL -r $(expr $SVN_OLD + 1 ):$SVN_NEW >logs.txt
svn diff $SVN_URL -r $SVN_OLD:$SVN_NEW >diff.txt
cat diff.txt | pygmentize -l diff -f html -O noclasses,nobackground -o diff.html
message=$(svn log $SVN_URL -r $SVN_NEW | sed -n '4{p;q}')
echo "<strong>Logs</strong><br /><pre>" >email.html
cat logs.txt >>email.html
echo "</pre><strong>Diff</strong><br />" >>email.html
cat diff.html >>email.html
cat email.html | mail -a "Content-type: text/html" -s "Core/SVN: r${SVN_NEW}: $message" $EMAILS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment