zedoo
zedoo

Reputation: 11277

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.

Upvotes: 1

Views: 702

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78330

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

Upvotes: 1

Related Questions