0

I am trying to figure out an efficient way of triggering some builds on different branches in a set order.

My setup is that i have 4 separate builds that all link together but need to be run on set branches.

Database
Client
Cucumber Tests
Library

At the moment I can run these in a set order on say a master branch, each build triggering the next one if successful.

But what I want to achieve is say i make a commit to Cucumber Tests but need any of the other jobs on a different branch, how could i handle that and still in the required order. I have read that there is such a thing as a Jenkins file and I could specify branches in there ? if so how would i then trigger the other jobs on the relevant branches?

Hopefully this makes sense but any questions then please ask

closed as unclear what you're asking by user246, IAmMilinPatel, Bharat Mane, NarendraC, ECiurleo May 9 '17 at 8:47

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Let me see if I understand. You always want to run the four builds in the same order. Each could potentially run in a different branch. And you want to control the correspondence between builds and branches without having to modify the builds. Is that right? – user246 Nov 3 '16 at 16:12
  • Hi, run builds in same order, yes.... each potentially run in different branch, yes..... the variation would be that any of the builds could start the process – Richlewis Nov 3 '16 at 16:18
  • Are there a fixed set of branches, or could any commit to any branch of any of the four builds start the process? – user246 Nov 3 '16 at 16:20
  • @user246 any commit to any of the four – Richlewis Nov 3 '16 at 16:21
  • @user246 any thoughts on this one at all please ? – Richlewis Nov 4 '16 at 9:19
1

You can cause the completion of one build to trigger another. You can also pass parameters to a build.

(Edit)

First, some terminology: I'll refer to each of Database, Client, Cucumber Tests, and Library as a repository. A job is how Jenkins defines it: a runnable task controlled/monitored by Jenkins. A build is an execution of a job.

Two Schemes

Two schemes for causing a version control commit to start a build would be Push and Pull. Push means the version control system takes an action that causes Jenkins to start a build. Pull means Jenkins polls the version control system for changes that justify starting a build.

Each scheme starts with creating a job with four parameters, one per build. Each parameter specifies a branch name.

Push

In a Push scheme, a build would be launched by a commit hook in the version control system. For example, if the OP uses Git, they can use the post-commit hook to determine which branch had changed and then issue an HTTP request to Jenkins to launch the build.

That assumes there is network connectivity between the committer and Jenkins, and that any Jenkins access control issues can be worked out.
If access control is not a problem but there is no network connectivity, it may be possible for commit hook to post a build request to an intermediary, and then for the intermediary to cause Jenkins to launch a build.

Pull

The goal for the Pull system would be to configure Jenkins to poll for changes in all branches of four repository. Jenkins has a Multiple SCMs Plugin that might do what you want. The documentation says the plugin was deprecated in favor of the Pipeline Plugin. You might try looking at that too.

Another option would be to create four "launcher" jobs, one per repository. Each launcher job would poll the version control system for changes in its corresponding repository. The Git Plugin supports polling all branches. When it detects change, it would launch a build with the appropriate branch information. You will have to research how to determine which specific branch has changed.

  • Hi, yes i understand this, but what if i make a commit to cucumber tests which is normally triggered third in the sequence but i need database to be on a particular branch, I need to ensure that the order of builds goes like database, client, cucumber tests, library. How would that be achieved – Richlewis Nov 3 '16 at 14:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.