How can I trigger a build of a certain revisions of a mercurial backed project in hudson?
I'm planning a mercurial changegroup hook that triggers a build in hudson.
The project gets added to the queue and hudson builds it 开发者_如何学运维when there's a free slot. The problem is, that somebody else may have pushed code to the project in the meantime, so hudson will build that newer revision (because it runs something like "hg pull -u && build"), not the revision the repository was at when the first build was triggered.
Is there any solution for that problem? Maybe using parametrized builds? If it doesn't work with a single job, maybe I can create one job per push and set the mercurial url to include a revision segment?
Thanks for hints.
In your hook, assuming it's a shell hook, you should get the node id of tip of your repo and pass that as an argument to Hudson's (now Jenkins's) API. Getting that value would look something like:
export NODE_TO_BUILD=$(hg --id --rev tip)
you'd then pass that as a parameter to Hudson's API using whichever format you're invoking: http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API
and tweak the Hudson job to be:
hg pull && hg update $NODE_TO_BUILD && build
精彩评论