Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hudson with Subversion: build after commit on Windows using Java or Ant

My task is to make Hudson starting a new build after a commit. As I've read here it is done by using svn post-commit hook. The problem is I don't want to use VBScript so that is is platform-dependent. As I can see the only important things in this VBScript are using svnlook command and http://server/subversion/${UUID}/notifyCommit?rev=$REV url. As far as I am concerned I can do the same thing just using, for example, a java program (which requires parameters as revision, repository location, etc.)

Can you, please, unravel the mystery of the http://server/subversion/${UUID}/notifyCommit?rev=$REV url? I need all possible variants. It would be great if sombody can describe the whole process of interaction with Hudson (it's internal processes' chain which execute after it gets this request)

EDIT I really need the post-commit behavior, not a polling mechanism.

like image 427
Dmitry Avatar asked Aug 26 '11 08:08

Dmitry


3 Answers

The quickest, cross platform solution is to install Cygwin on the SVN server (assuming the SVN box is running Windows) and use the suppiled shell script:

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://server/subversion/${UUID}/notifyCommit?rev=$REV

I need all possible variants of http://server/subversion/${UUID}/notifyCommit?rev=$REV

Why? That one does all you need.

  • server The Jenkins server
  • ${UUID} The unqiue ID for the repository.
  • $REV The new revision.

You could also just use something in the post-commit hook to ping: http://YOURHOST/jenkins/job/PROJECTNAME/build. You will not get a fresh build for every commit, but if you have two commits within seconds of each other do you really want each built?


Just out of curiosity, do you want the post commit as you have found your SVN server getting incredibly slow? If so, what OS is the SVN box on? You might be hitting limits of the OS and you would get much better performance (on the same tin) if you moved to Linux or a server edition of Windows.

like image 76
Michael Lloyd Lee mlk Avatar answered Oct 06 '22 19:10

Michael Lloyd Lee mlk


You don't necessarily need to use a svn hook. Just make Hudson poll the repo for changes frequently. Additionally you might want to employ a quiet period in order to account for multiple commits in a row (which otherwise might trigger multiple builds).

From the link you posted:

Jenkins can poll Subversion repositories for changes, and while this is reasonably efficient, this can only happen up to every once a minute, so you may still have to wait a full minute before Jenkins detects a change.

I wouldn't consider having to wait a minute that big a problem. In most cases you might not even notice it.

like image 26
Thomas Avatar answered Oct 06 '22 20:10

Thomas


I've done it like this: I configured hudson to check every minute for changes (Pattern: * * * * *). It works quite good. The only problem which can occur is that if two projects which have been commited within this interval and are dependent on each other, that hudson builds the wrong one first.

like image 1
kukudas Avatar answered Oct 06 '22 20:10

kukudas