An alternative way of invoking jenkins after svn commit


This page assumes that you have already setup the following in your Ubuntu 12.04 system:
1.) Jenkins
2.) Artifactory
3.) SVN

Normally we use this plugin: https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin, where we edit the svn's post-commit hook and write the following code, but it doesn't work for me :-) (we assume that you have your repositories in /var/subversion):

#!/bin/sh

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`

/usr/bin/wget \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "'svnlook changed --revision $REV $REPOS'" \
  --output-document "-" \
  --timeout=2 \
  http://localhost:8080/subversion/${UUID}/notifyCommit?rev=$REV

To test if your post commit is working you can temporarily change it's contents into:

#!/bin/sh
/bin/echo "$REPOS $REV $UUID" >> /var/subversion/svn-post-commit.out

To call the subversion jenkins plugin normally this should work (but it also did not :-))

curl --data "rev=4" http://localhost:8080/subversion/c8bb87ec-9a19-4975-ab9d-8b15741e6d7e/notifyCommit

Check if a file is created and has content in: /var/subversion/svn-post-commit.out
So what worked for me? I just manually invoke jenkins's cli.jar. So I changed the post-commit content into:

#!/bin/sh

/usr/bin/java -jar /usr/share/jenkins/cli/java/cli.jar -s http://localhost:8080/ build yourProject

*Note: Make sure that www-data user has permission to execute cli.jar.

{ 0 comments... read them below or add one }