How to configure Jenkins to build project from different branches in Mercurial
Asked Answered
H

2

12

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.

Hydrolysis answered 16/2, 2012 at 3:45 Comment(0)
G
3

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).

Gandhiism answered 16/2, 2012 at 11:54 Comment(0)
N
5

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

Neglectful answered 5/9, 2012 at 19:51 Comment(0)
G
3

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).

Gandhiism answered 16/2, 2012 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.