l0b0
l0b0

Reputation: 58808

How to execute only the most recent queued job in Jenkins?

I've got a commit build project in Jenkins which schedules an acceptance build project on completion. Since commits come in faster than the acceptance build job finishes, after a short time there are now six queued acceptance build jobs. I would like the acceptance build project to work like the "Poll SCM" functionality - On completion, start the most recently queued job, skipping the rest.

I can't use the "Build after other projects are built" without more hacks since I need to pass information from the commit build job to the acceptance build job.

Upvotes: 3

Views: 4756

Answers (1)

333kenshin
333kenshin

Reputation: 2045

@l0b0,

Jenkins behavior is to coalesce builds so that the queue only contains the currently running build and one enqueued job. The depth only increases if the newly enqueued jobs takes parameters that differ from what's already on the queue.

So I'm gathering that your downstream (acceptance) job takes some sort of parameters, but you need to supply more details of how it's working.

If you're using parameterized trigger plugin then you should check out this existing SO thread

More generally speaking, you should look into your parameters. It sounds like you are passing too much information from upstream to downstream jobs, resulting in the the Jenkins queue treating them as distinct parameters when then is not necessarily the case.

Are you passing in the run number of the last successful upstream job as a parameter? If so, then yeah you've got problems. What you should do instead is use the Promoted Build Plugin on the upstream job to mark the last successful build, and then have the downstream job simply jump to the most recent promoted build.

Hope that helps.

Upvotes: 7

Related Questions