Felipe Caldas
Felipe Caldas

Reputation: 2503

Aggregating test results in Jenkins with Parametrized Jobs

I understand this post is similar to: Aggregating results of downstream is no test in Jenkins

and also to: Aggregating results of downstream parameterised jobs in Jenkins

Nonetheless, I am not able to figure out for my case, how to make this working. I am currently using Jenkins 1.655.

I have jobs A, B, C - A being the upstream job. What I want to do is to have A call B and B call C. All needs to block and wait for completion of the next. If one fails, all fails. B and C generate unit test reports. So I want to aggregate these reports in A and then Publish that result in A. So, here's the current setup of the jobs:

Job A:

Build Steps

  1. Execute shell: echo $(date) > aggregate
  2. Trigger Parametrized Buid Job: Job B

Post Build Steps

  1. Aggregate downstream test results
  2. Record fingerprints of files to track usage: set Files to fingerprint to aggregate
  3. Publish JUnit test result report (report files from B and C)

Job B:

Build Steps

  1. Copy artifacts from another project: copy from upstream job aggregate file
  2. Run tests to generate unit test reports
  3. Trigger Parametrized Build Job: Job C

It ultimately fails here because aggregate is only archived in the Post Build Steps of Job A. How can I archive an artifact in the Build Step?

Post Build Steps

  1. Aggregate downstream test results (unit test.xml generated)
  2. Record fingerprints of files to track usage: set Files to fingerprint to aggregate

I won't post Job C here for simplicity but it follows pretty much what B does.

So, summing it up, I want to have interlinked jobs that depend on each other and uses the parametrized plugin and the upstream job must aggregate the test results of all downstream.

Any help appreciated, thanks!

Upvotes: 0

Views: 3419

Answers (1)

Dvir669
Dvir669

Reputation: 8600

  1. If you have no limitation on where to run your jobs you can always specify it to run on the same workspace\machine - this will solve all your issues.
  2. If for some reason you can't run it on the same workspace, instead of using the copy artifact plugin you can use the link in Jenkins to the WS (guessing you're using Parameterized Trigger Plugin) so it'll be easy to wget the "aggregate" file from A job from the triggered job using the defined: TRIGGERED_BUILD_NUMBER_="Last build number triggered" from A. This will also help you to keep track of the jobs B and C you triggered to get the artifacts from there.

Hope it helps!

Upvotes: 1

Related Questions