views:

285

answers:

5

There are 4 jobs:

Build1  
Build2  
Test1  
Test2

Build1 and Build2 can be started simultaneously.
Test1 should be started only when both Build1 and Build2 will be finished.
Tes2 should be started only when Tes1 will be finished.
Also I would like to have ability to start all of these jobs separately.
Is there any way to setup jobs according these rules?

+2  A: 

When creating a new job, you normally can specify what upstream project must be built in order to begin this job.

This option is in Build Triggers -> Build after other projects are built when creating/modifying a job.

Valentin Rocher
I would like to start **Build1** and **Build2** simultaneously. But I cannot configure **Test1** in order to start it when both **Build1** and **Build2** will be finished. It is possible to start **Test1** when either **Build1** or **Build2** will be finished. Am I right?
Vladimir Bezugliy
You will also need to check "Block build when upstream project is building" under Advanced Project Options. This will prevent Test1 from building if Build1 or Build2 are in the queue.
TK
I do not have such option. What version of Hudson do you use?
Vladimir Bezugliy
+1  A: 

I think you have several options. My assumption is, that we are talking about long running jobs, otherwise I would just string them together as one monster job (several build steps in one job) and create separate jobs for running them individually.

As mentioned, for long running jobs, have a look at the join plugin. As a general FYI there is a page explaining why you want to separate testing jobs from the building jobs. See here.

Peter Schuetze
The Join plugin is the key here.
William Leara
A: 

I'm running version 1.346 of Hudson.

You can check 'Build after other projects are built' under 'Build triggers'.

It says that "Multiple projects can be specified like 'abc, def'"

So you should be able to add 'Build1, Build2' to that field in the configuration for Test1.

Klelky
From the help text for 'build after projects are build': *Set up a trigger so that when some other projects finish building, a new build is scheduled for this project. This is convenient for running an extensive test after a build is complete, for example.* -- so essentially, Test1 will be triggered when either build one or two is done, not after two are done. In this particular case, you might be able to get around that problem with the locks-and-latches plugin.
Peter Schuetze
A: 

You could keep your Test1 & Test2 as separate jobs, instead of being a part of the builds.

When Build1 and Build2 are complete, Test1 can start as a downstream build. Test2 can be a downstream job from Test1.

Sagar
A: 

The "Promoted Builds Plugin" can be a good solution: you can configure a master job "Build" to do nothing but start 2 downstream builds "Build1, Build2" (in post-build actions). Then you have to add a promotion process "When the following downstream projects build successfully" selecting "Build1, Build2", with an associated downstream build action of "Test1". If "Build1" and "Build2" build sucessfully (both status STABLE), "Build" will be promoted and "Test1" will be enqueued. Finally, you trigger Test2 as a post-build action of Test1.

But you have to be aware that is case many instances of "Build" are enqueued, you cannot rely on the lastSuccessful build permalink (the next "Build1" or "Build2" may already be built when "Test1" called by the first "Build" will pop-out of the queue), and you will have to devise a way to keep track of the revision of the build you are testing.

Parameterized Trigger Plugin can help solving this problem: you could pass the id of the upstream build as a parameter, for example.

fractule