Build blocker does not block on node level

24 views
Skip to first unread message

Denis Mone

unread,
Nov 4, 2019, 10:54:07 AM11/4/19
to Jenkins Developers
Hello.
We have build-blocker plugin installed on our Jenkins installation in my company, and we discovered that the node level blocking does not work.
Scheduling two mutually excluded jobs on the same node for example succeeds.
From a quick google search i found out that there is a similar issue reported on jira JENKINS-50187

I cloned the repo and managed to run the plugin, and by going through the code i think that the issue may be on getBuildBlockerProperty method.
When canRun method of BuildBlockerQueueTaskDispatcher class is called the method correctly returns the property object.
But when canTake method is called it returns null, which implies that the node can take this job in order to build it.

@CheckForNull
private BuildBlockerProperty getBuildBlockerProperty(Queue.Item item) {
   
if (!(item.task instanceof Job)) {
       
return null;
   
}
   
Job<?,?> job = (Job<?,?>) item.task;

   
return job.getProperty(BuildBlockerProperty.class);
}


Can anyone who is familiar with Pipeline API to point me to a direction where i can solve this issue?


Denis Mone

unread,
Dec 6, 2019, 12:43:50 PM12/6/19
to Jenkins Developers
I have added another if statement on the method to check if ownerTask is instance of Job class. If its true then go ahead and get the property.
            if (!(item.task.getOwnerTask() instanceof Job)) {
               
return null;
           
} else {
               
return ((Job<?, ?>) item.task.getOwnerTask()).getProperty(BuildBlockerProperty.class);
           
}

This seems to solve the issue, at least when running the plugin locally.


 
Reply all
Reply to author
Forward
0 new messages