5

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.

Dmitry
  • 3,028
  • 6
  • 44
  • 66
  • Why do you need post-commit behaviour? Polling is as legitimate as push notification. –  Aug 26 '11 at 09:31
  • Because normally, our team use this repository no more than once a week. But it is possible to have some circumstances under which commits can be more often. The traffic is critical. So that the decision was made. =) – Dmitry Aug 26 '11 at 09:43
  • You can set the polling interval to something like very 15 minutes or hour if you don't want to incur polling load on every minute. I'm sure your team can wait 15 minutes after the checkins. – Cem Catikkas Aug 26 '11 at 14:36
  • Well, it is an idea. but not what I really need. =) As I've written, I need a post-commit behavior. – Dmitry Aug 26 '11 at 14:42

4 Answers4

4

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.

Michael Lloyd Lee mlk
  • 14,561
  • 3
  • 44
  • 81
  • Thank you very much for your answer. Making Windows to behave as Linux seems a bit overhead. On the other hand it has become a challenge to make it work on pure Windows. The 'ping' idea is really helpful! – Dmitry Sep 04 '11 at 08:54
  • to mlk: the main reason is not performance. It is more to architectural issue. Something like a post office. You can check if there is a letter for you every hour or you can wait for a notification. – Dmitry Sep 04 '11 at 09:00
  • And UUID is an id which SVN dedicates to the repository (on creation) or it is an id on which Hudson registers the current repository (and then how can I know it?) ? – Dmitry Sep 04 '11 at 09:05
  • The UUID is an SVN UUID. The SVN command svnlook uuid svn://svn/repository will tell you it. I consider Cygwin a standard part of any developer machine set up, so IMO the overhead is none existent. – Michael Lloyd Lee mlk Sep 09 '11 at 12:43
  • Regarding the reason: I'd recomend you just go with hitting the http://YOUR_JENKINS_HOST/jenkins/job/PROJECTNAME/build then. With[wget](http://gnuwin32.sourceforge.net/packages/wget.htm) (or alike) it is a simple one line bat script. – Michael Lloyd Lee mlk Sep 09 '11 at 12:51
2

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.

Thomas
  • 87,414
  • 12
  • 119
  • 157
1

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 scriptHere is what you have to select while creating your job that would be called when commit occurs

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
Community
  • 1
  • 1
1

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.

kukudas
  • 4,834
  • 5
  • 44
  • 65