Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - trigger job after all downstream jobs have completed, not only the immediate ones

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.

like image 561
aleung Avatar asked Sep 04 '12 08:09

aleung


People also ask

What is the difference between upstream and downstream in Jenkins?

An upstream job is a configured project that triggers a project as part of its execution. A downstream job is a configured project that is triggered as part of a execution of pipeline.

How do you trigger another job in Jenkins using pipeline with parameters?

You can follow the below steps to trigger a Jenkins pipeline in another Jenkins pipeline. Select a job that triggers a remote one and then go to Job Configuration > Build section > Add Build Step > Trigger builds on remote/local projects option.

Can a Jenkins job trigger another Jenkins job?

Use build job plugin for that task in order to trigger other jobs from jenkins file. You can add variety of logic to your execution such as parallel ,node and agents options and steps for triggering external jobs.


2 Answers

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

like image 140
Yogesh Avatar answered Oct 28 '22 06:10

Yogesh


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.

like image 45
Jason Swager Avatar answered Oct 28 '22 06:10

Jason Swager