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 re开发者_如何转开发quires 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.
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.
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.
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.
Important - None of the article on web clearly mentions about the job that you have to create with "Trigger Build Remotely" checked. This is the first step and this step itself gives you URL that you have to put in your subversion HOOK script
corresponding hook script
!/bin/sh
REPOS="$1"
REV="$2"
/usr/bin/wget \
--header "Content-Type:text/plain;charset=UTF-8" \
--post-data "`/usr/local/bin/svnlook changed --revision $REV $REPOS`" \
--output-document "-" \
--timeout=2 \
http://build.development.com:8080/job/HdsVp/build?token=SVN_CHANGE
精彩评论