Can Hudson be configured to build every revision?
Asked Answered
H

5

7

I've started experimenting with Hudson as a build server. I'm using subversion and have it configured to poll every minute. The issue I'm seeing is that if a build at revision 10 takes 5 minutes and there are 5 commits during that time, Hudson will next build revision 15.

Is there a way to ensure every revision is built?

Heilungkiang answered 4/6, 2009 at 7:44 Comment(4)
You have to take care that this wont cause performance problems for Hudson. For example, if you have commits happening every few seconds, whereas a hudson build takes a few minutes. Soon you will flood the build queue.Beaverbrook
For the life of me, I can't see why this could be needed. Why would something other than the current state of the codebase be important?Petasus
Hi sal, the reason for this is testing. We aim to put each revision through a regression test. So if we are not building each revision, we are not testing each revision. This causes issues if rev n is working but rev n+10 isn't and we didn't test any of the revisions between. Which change caused the regression?Heilungkiang
I believe Hudson now has a checkbox on the job configuration marked "Allow concurrent builds"...Gameness
S
4

Hudson does not yet have this capability, but its been asked for a few times on the mailing list. See issue 673

Swipe answered 25/6, 2009 at 12:35 Comment(1)
I looked up that bug. The bug tracker has moved, the issue is now at issues.hudson-ci.org/browse/HUDSON-673 and it is still unresolved.Damales
J
10

You have to do a few things to build exactly each revision:

  • add a REVISION string parameter to your job
  • append the ${REVISION} parameter to the repository URL,
    e.g.: https://server/path/myproject${REVISION}
  • set the name of the local folder to 'myproject' (see previous example), because the REVISION variable is only expanded in the URL, but when creating the folder, Hudson will not expand it, resulting in a folder named: myproject${REVISION}
  • trigger the parameterized build from the post-commit hook, like that: /usr/bin/wget \ --auth-no-challenge \ --no-check-certificate \ --user=me \ --password=mypasswd \ https: //server/path/job/jobname/buildWithParameters?delay=0sec\&REVISION=%40$REV \ -O /dev/null

If you want to trigger a build manually, you have two possibilities:

  • if you want to build HEAD revision, you must leave the REVISION parameter empty
  • if you want to build a specific revision, you have to enter @NNN (eg: @1234).

The @ sign is very important because all this trick relies on the fact that Subversion plugin interprets URL@NNN as get revision NNN from repository at URL. If you forget the @, Subversion will just say it can't find folder https://server/path/myprojectNNN. That's also why you have to put %40 between REVISION= and $REV in the wget command, %40 is the escaped character for @.

Jenson answered 6/5, 2010 at 10:4 Comment(0)
S
4

Hudson does not yet have this capability, but its been asked for a few times on the mailing list. See issue 673

Swipe answered 25/6, 2009 at 12:35 Comment(1)
I looked up that bug. The bug tracker has moved, the issue is now at issues.hudson-ci.org/browse/HUDSON-673 and it is still unresolved.Damales
U
1

In SCM part of build configuration you should have Build Triggers section and option "Trigger builds remotely (e.g., from scripts)". According to help info next to that option you can script post-commit action so every commit would fire new build. As hudson has build's queue you should have every revision built.

Here's a link that could help you: https://hudson.dev.java.net/build.html

Here's example how to start build job with parameters (see to my comment for details): http://wiki.hudson-ci.org/display/HUDSON/Parameterized+Build

Uniformity answered 4/6, 2009 at 7:51 Comment(3)
Not sure that'll work directly - the first commit will trigger a build, then 3 commit trigger 3 further builds before the 1st finishes. Unfortunately, the second build in the queue will then do an update and build the latest version - as will the following builds. What's needed to to be able to pass a revision number to the build request and have that number used during the update.Pyrogallol
You're right, I haven't thought about that obvious scenario. But as I've seen in hudson documentation it is possible to invoke build job with parameters so you could define build string parameter RevisionToBuild and set it from the script like that: "server/job/myjob/buildWithParameters?RevisionToBuild=1234" and of course properly modify svn repository path to use that parameter.Uniformity
But you can make the build queue just one job deep (for a given build executor set the "# of executors") and this will get the result you're after...even if parallel builds would be faster.Dissolve
C
0

The key to make sure every commit is built in Hudson is "Parameterized Build" and ONLY IF trigger build with different parameter values, hudson will think it's new build and should be held in build queue. Or it won't be recorded by Hudson since it consider it's meaningless build compared with previous one

e.g. you can click "Build Now" to trigger build for three times and just leave the build para as "null". you will see only first two builds are in Hudson queue. The third one will be ignored :P cool but it's really bad that it's not found in some document but with my experiments for times :(

Conserve answered 6/5, 2010 at 22:58 Comment(0)
D
0

I took fchateaus approach above (thanks man!) and modified it to work with Mercurial.

You will need to edit .hg/hgrc on the central server, and put in a changegroup hook. Keep in mind that changegroups only set the first changeset to the HG_NODE environment variable, so you have to do a hg tip to grab the real tip node and pass that along via URL instead. A bit of a trick to do in a one-liner, but I figured it out.

This is what you would do for Hudson running on Windows.

[hooks]
# this uses wget to hit the hudson url responsible for starting a build - %HG_NODE% only gets first changeset of changegroup, so use hg tip to grab changeset most recently added instead
changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/buildWithParameters?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G
# TODO: when Hudson implements polling with parameters, change to something like this
#changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/polling?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G
Devitt answered 30/12, 2010 at 20:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.