Τη Δευτέρα, 4 Νοεμβρίου 2019 - 5:54:07 μ.μ. UTC+2, ο χρήστης Denis Mone 
έγραψε:
>
> 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 
> <https://issues.jenkins-ci.org/browse/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?
>
> 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.


 

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/b35aa7bf-dd22-48d2-8a88-2b5ac491bf5d%40googlegroups.com.

Reply via email to