Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Jenkins to build project from different branches in Mercurial

I have a Jenkins build job with a Mercurial trigger on the default branch, which works fine for building "release candidates". This job then starts a smoke test job.

We use a branch-per-feature branching scheme, so that at any given time there could be up to a dozen different active branches in Mercurial (but the active branches change regularly).

I would like a Jenkins job triggered by changes to any branch, that will then build and run the smoke tests for all branches that need updating. Each time we do a build, we should create artifacts named to match the branch.

I saw a suggestion in another answer of using "tip" instead of the branch name in the Mercurial trigger - this is a possibility, but I think it would fall into the "mostly works" category. The trigger is polling, so if changes to more than one branch occur within the polling interval, then a branch update could be missed.

I could create a new job each time a branch is created, but due to the dynamic nature of our branches, that would be a lot of ongoing work.

like image 366
Alistair Ward Avatar asked Feb 16 '12 03:02

Alistair Ward


2 Answers

If you decide to go with the job for every branch approach, the following tools can make the task a bit more manageable:

  • jenkins-build-per-branch (supports git)
  • jenkins-autojobs (supports git, mercurial and svn)
like image 114
gvalkov Avatar answered Nov 10 '22 12:11

gvalkov


I think you'll need to customize: the top-level polling job (tuned to tip) runs a custom script that determines branches that have changed or have been added. It then will use Jenkins API to start a job parameterized by the branch name. That parameter can be used in your job to customize everything you need by the branch name (including the artifacts).

like image 39
malenkiy_scot Avatar answered Nov 10 '22 13:11

malenkiy_scot