We want to dynamically trigger integration tests in different downstream builds in jenkins. We have a parametrized integration test project that takes a test name as a parameter. We dynamically determine our test names from the git repo.

We have a parent project that uses jenkins-cli to start a build of the integration project for each test found in the source code. The parent project and integration project are related via matching fingerprints.

The problem with this approach is that the aggregate test results doesn't work. I think the problem is that the "downstream" integration tests are started via jenkins-cli, so jenkins doesn't realize they are downstream.

I've looked at many jenkins plugins to try to get this working. The Join and Parameterized Trigger plugins don't help because they expect a static list of projects to build. The parameter factories available for Parameterized Trigger won't work either because there's no factory to create an arbitrary list of parameters. The Log Trigger plugin won't work.

The Groovy Postbuild Plugin looks like it should work, but I couldn't figure out how to trigger a build from it.

Nevermind. I see "build - the current build (see hudson.model.AbstractBuild)" on the Groovy Postbuild Plugin page. I don't think that existed when I asked the question or wrote my answer.
–
willkilJun 17 '14 at 15:25

To start a downstream job with parameters, you have to add a ParametersAction. Suppose Job1 has parameters A and C which default to "B" and "D" respectively. I.e.:

A == "B"
C == "D"

Suppose Job2 has the same A and B parameters, but also takes parameter E which defaults to "F". The following post build script in Job1 will copy its A and C parameters and set parameter E to the concatenation of A's and C's values:

Since you are already starting the downstream jobs dynamically, how about you wait until they done and copy the test result files (I would archive them on the downstream jobs and then just download the 'build' artifacts) to the parent workspace. You might need to aggregate the files manually, depending if the Test plugin can work with several test result pages. In the post build step of the parent jobs configure the appropriate test plugin.

Using the Groovy Postbuild Plugin, maybe something like this will work (haven't tried it)

def job = hudson.getItem(jobname)
hudson.queue.schedule(job)

I am actually surprised that if you fingerprint both jobs (e.g. with the BUILD_TAG variable of the parent job) the aggregated results are not picked up. In my understanding Jenkins simply looks at md5sums to relate jobs (Aggregate downstream test results and triggering via the cli should not affect aggregating results. Somehow, there is something additional going on to maintain the upstream/downstream relation that I am not aware of...

I finally got a chance to try this out, 9 months later. Your code doesn't work, but it got me started. The script has to say manager.hudson instead of hudson. The Join Plugin then gives an error saying a CauseAction is required, so I used manager.hudson.queue.schedule(job, 0 causeAction). Thanks for giving me the spark I needed.
–
willkilDec 7 '12 at 22:33