Class PriorityEnforcingDispatcher

java.lang.Object
hudson.model.queue.QueueTaskDispatcher
cz.mendelu.xotradov.PriorityEnforcingDispatcher
All Implemented Interfaces:
ExtensionPoint

@Extension(ordinal=1.7976931348623157E308) public class PriorityEnforcingDispatcher extends QueueTaskDispatcher
A QueueTaskDispatcher that enforces the Simple Queue priority ordering when items transition from blocked to buildable.

The problem it solves: Jenkins Queue's maintain() method processes blocked items one by one. When a blocked item's constraint clears (causeOfBlockage becomes null), it is immediately added to the buildables list — regardless of its priority relative to other still-blocked items. This means a lower-priority item can start building before a higher-priority item even becomes unblocked.

This dispatcher intercepts the transition by implementing canRun(Queue.Item). When an item is about to become buildable, it checks whether there are higher-priority items still blocked. If so, it returns a non-null CauseOfBlockage to hold the item back until those higher-priority items are also unblocked.

The priority check uses SimpleQueueComparator, which respects both explicit user desires (arrow moves) and timestamp-based fallback ordering.