File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
src/main/java/jenkins/branch Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -533,22 +533,23 @@ public CauseOfBlockage canRun(Queue.Item item) {
533533 }
534534 // ensure items leave the queue in the order they were scheduled
535535 List <Queue .Item > items = Jenkins .get ().getQueue ().getItems (item .task );
536- if (!items .isEmpty ()) {
537- Queue .Item i = items .get (0 );
538- if (item == i ) { // This item is the first in queue for this task.
539- LOGGER .log (Level .FINE , () -> "Allowing " + item .getId () + " " + item .getClass ().getSimpleName () + " " + job .getFullName ());
540- return null ;
541- } else {
542- // There is another item before the one currently processed, so block.
543- LOGGER .log (Level .FINE , () -> item .getId () + " " + job .getFullName () + " blocked by queue id " + i .getId () + " was first" );
536+ if (items .size () == 1 && item == items .get (0 )) {
537+ return null ;
538+ }
539+ for (Queue .Item i : items ) {
540+ if (i .getInQueueSince () < item .getInQueueSince ()) {
541+ LOGGER .log (Level .FINE , "{0} with queue id {1} blocked by queue id {2} was first" ,
542+ new Object []{
543+ job .getFullName (),
544+ item .getId (),
545+ i .getId ()
546+ }
547+ );
544548 long betweenBuilds = property .getMillisecondsBetweenBuilds ();
545549 return CauseOfBlockage .fromMessage (Messages ._RateLimitBranchProperty_BuildBlocked (
546550 new Date (System .currentTimeMillis () + betweenBuilds ))
547551 );
548552 }
549- } else {
550- // Defensive measure, the queue item is supposed to be in queue already.
551- LOGGER .log (Level .WARNING , "Could not find queue item with id=" + item .getId () + " in queue." );
552553 }
553554 }
554555 }
You can’t perform that action at this time.
0 commit comments