10

The Jenkins Join Plugin allows a job to be run after all the immediate downstream jobs have completed.

But how can I configure a job to be run after all downstream jobs have completed, not only the immediate ones?

This figure shows the jobs triggering flow I expect:

                           A
                           |
                    --+----+------+--
                      |           |
                      v           v
                      B           C
                      |           |
     --+--------+-----+---+--     |
       |        |         |       |
       v        v         v       |
       D        E         F       |
       |        |         |       |
       v        |         |       |
       G        |         |       |
       |        |         |       |
    ---+--------+----+----+-------+--
                     |
                     v
                     J

I set Join Trigger on job A to trigger the final job J. However job J is started once B and C are finished, does not wait for jobs D,E,F and G.

In this answer and its comments, it said that the paths can be multiple jobs deep and fingerprints must be correctly used. But I can't figure out how to make it work.

Community
  • 1
  • 1
aleung
  • 9,848
  • 3
  • 55
  • 69

2 Answers2

7

In case someone is looking for easy way just use JobFanIn plugin. This plugin will allow you to set trigger on job J once C, E, F & G are build and stable

Yogesh
  • 4,546
  • 2
  • 32
  • 41
  • 2
    Exactly what i needed, simple build dependency solution thanks. – syncdk Jun 03 '16 at 17:01
  • doesnt let you pass parameters from the upstream job to the merged job. – Ace McCloud Jul 18 '16 at 21:12
  • thats a limitation I guess. May plugin can be enhanced to do that but with multiple upstream projects passing parameters will have to handling it downstream job as well. Will see if this can be added in plugin – Yogesh Jul 19 '16 at 04:54
5

The Join plugin works only when everything is broken up into "diamonds" of dependencies: a single starting job, one or more downstream jobs, but only one level deep (D and G are two levels deep in your diagram), followed by a single joined job. Your dependency structure doesn't follow that diamond pattern.

For this particular situation, I would use the Promoted Builds Plugin. Setup Job A to have a promotion that when triggered, runs Job J. Make the trigger for that promotion be the successful completion of B, C, D, E, F, G. Or if want to minimize it: G, E F, C. Just make sure that fingerprinting is setup correctly.

For the fingerprinting, generate a file (or choose an existing file) during Job A. Artifact it and fingerprint it. In all the following jobs B-G, use the CopyArtifact plugin to retrieve that file into the job and fingerprint it there as well.

Jason Swager
  • 6,421
  • 6
  • 41
  • 56
  • Can you elaborate a bit the fingerprinting and promoted build setup? I asked almost the same question [here](http://stackoverflow.com/questions/26101765/jenkins-pipeline-top-level-join-gets-triggered-before-sub-level-join) – dstj Sep 30 '14 at 16:16
  • Done - answer has been updated with additional information on fingerprinting. – Jason Swager Sep 30 '14 at 22:09