Simankov
Simankov

Reputation: 189

Jenkins run same job twice

I have job A which trigger job B and job C. Job B trigger job D and job C trigger job D. So after building job A I get two running D jobs. I want to run job D only once after building job A (B and C must be already builded) .How can I achieve it?

Upvotes: 0

Views: 3298

Answers (3)

yorammi
yorammi

Reputation: 6458

If you prefer not to use Jenkins pipeline (which is the best solution for the issue), you can consider using Multi-job plugin instead.

Upvotes: 0

saurabh14292
saurabh14292

Reputation: 1401

Handling parallel build jobs/diamond dependencies etc, are better done with pipeline. In pipeline-as-a-code/groovy/jenkinsfile etc.

If you do not have option to use any of them and can do only with jobs, I suggest have a look for JobFanIn plugin.

https://wiki.jenkins.io/display/JENKINS/JobFanIn+Plugin

Post installation, configure the Job D to watch for Job B and Job C. Once B and C are triggered by A and once both are complete then only job D will be executed.

Upvotes: 0

Rob Hales
Rob Hales

Reputation: 5319

The reason pipeline jobs were invented is to handle these more complex types of conditions. Rather than installing various plugins that trigger other jobs, or wait for different jobs, try to program logic in a UI, etc., you put all the individual jobs in stages of a pipeline (or call them from stages of a pipeline) and all this logic becomes easy.

If you already have all the jobs setup, Try using a simple trigger job with some pipeline logic to call the other jobs and execute the in the appropriate order and the right number of times.

Upvotes: 1

Related Questions