Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround: Aggregate downstream test results

Tags:

jenkins

As far as I know, the feature "Aggregate downstream test results" does not work as expected (and it is very hard to find useful documentation). I'd like to achieve very similar functionality:

Job Build triggers jobs T1, T2 in parallel (where T1 does FindBugs, T2 does PMD).

Scenario 1: As soon as T1 and T2 are finished (which I can achieve using the "Join" plugin) I want to gather the artifacts (T1/findbugs.xml and T2/pmd.xml). Then these are analyzed and nice statistics are generated.

Scenario 2 (I like this more): Like scenario 1, but the analysis is done as part of T1 and T2 (in parallel!). As soon as T1 and T2 are finished, the analysis results are combined into nice statistics.

My questions: For scenario 1 I do not know how to reference the downstream projects T1 and T2. I could use the last successful build, but that seems weird when considering many parallel jobs.

For scenario 2 I have no idea how to import the data that is needed for the FindBugs/PMD/Checkstyle/SLOCcount/... plugins so that the corresponding graphs (also?) appear outside of T1/*T2*.

Thanks, Carsten

like image 981
C-Otto Avatar asked Jun 15 '12 13:06

C-Otto


1 Answers

Here is an outline for a somewhat simpler scenario, but I think you can easily generalize it to your case of multiple downstream jobs. The trick is to use "marking" parameters in downstream jobs.

Let P be the parent job and D be a downstream job.

  1. An instance (build) of P invokes D via Parameterized Trigger Plugin via a build step (not as a post-build step) and waits for D's to finish. Along with other parameters, P passes to D a parameter - let's call it PARENT_ID - based on P's build's BUILD_ID.
  2. D executes the tests and archives them as artifacts (along with jUnit reports - if applicable).
  3. P then executes an external Python (or internal Groovy) script that finds the appropriate build of D via PARENT_ID (you iterate over builds of D and examine the value of PARENT_ID parameter). The script then copies the artifacts from D to P and P publishes them.

If using Python (that's what I do) - utilize Python JenkinsAPI wrapper. If using Groovy - utilize Groovy Plugin and run your script as system script. You then can access Jenkins via its Java API.

like image 125
malenkiy_scot Avatar answered Oct 01 '22 18:10

malenkiy_scot