Limit queued pending jobs

Hello,

I want to limit the number of queued instance of a same job while one instance is currently in construction.

To give more context:
I have a job triggered by some events. The job can be triggered while another instance is already running. If it happens I don’t allow concurent builds, so the new instance of the job is queued, that’s fine. But I want to only have one instance of job queued not more.

The throttle system helps a bit but it is more a workaround than a real solution

Thanks.

Christophe

Perhaps there is an easier way, but I think the lock step from the lockable resources plugin can be used for this, if given the skipIfLocked parameter.

In such use though, the pipeline would have to allocate the agent inside the lock step, rather than outside, so that Jenkins can check the lock immediately even if all agents are busy.