Search code examples
svnjenkinspost-commit-hook

Trouble with SVN post-commit and Jenkins


I am trying to get CI going with Jenkins. To date, we have been performing two scheduled builds in our environment, but our dev staff wants to get CI working. I have followed the instruction outlined in the Jenkins Subversion Plugin wiki page:

https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin

This got me to a script that executes at the command line just fine, however when I commit a change in Subversion (using the TortoiseSVN client), the commit seems to hang and I don't see Jenkins getting notified.

Here is my script:

#!/bin/sh

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`
XSLT_FILE=/var/www/svn/codelog.xslt
RSS_FILE=/var/www/html/code_all.rss
MAX_RESULTS=40

/usr/bin/wget \
  --auth-no-challenge \
  --no-check-certificate \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --output-document "-" \
  --timeout=2 \
  https://192.168.100.16/subversion/${UUID}/notifyCommit?rev=$REV
svn log "file://$REPOS" --limit "$MAX_RESULTS" -v --xml | xsltproc "$XSLT_FILE" - > "$RSS_FILE"

The RSS feed was already in the script. That has been working for over a year.

I have updated the file permissions as well, in case that was the problem:

[root@Subversion hooks]# ls post-commit -ao
-rwxrwxr-x 1 apache 530 Jul 17 06:27 post-commit

Solution

  • I have never liked how the SVN Plugin page is written. It is to easy to read it to say that you need to set up a Post Commit Hook in SVN to make things work. You Don't!

    We have about 10 builds on our Jenkins box. All of them are linked to SVN repositories, and all a triggered by changes in the SVN repository. None of them rely on having to use a Post Commit Hook in SVN.

    To do this, we have configured the builds to simply "Poll SCM" on a schedule. The "commit" builds use a schedule of "*/5 * * * *". This polls every 5 minutes. Our "daily" builds use a schedule of "1 1 * * *" so that the builds would kick off at 1:01 AM if there are any changes.