9
votes

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.

2

2 Answers

6
votes

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

5
votes

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.