-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
-
2616.v07df00c08d42
Hi,
Took me a while to understand why tools were not installed on running agent even if the labels were set on the node.
I happen that the https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tools/ToolInstaller.java#L87 doesn't consider assigned labels (Typically the ones created by LabelFinder extensions). Like https://github.com/jenkinsci/platformlabeler-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/platformlabeler/PlatformLabeler.java#L40
It's specially true of ephemeral agent and tool directive installation. Dynamic labels are assigned "too late" on the build.
I propose to change it to (not tested)
public boolean appliesTo(Node node) { Label l = Jenkins.get().getLabel(label); return l == null || node.getAssignedLabels().contains(l); }
Any thought ?
- links to
The label could be a labelexpression e.g. a || b
With your change this would never match whereas the existing approach should work also for label expressions.
Dynamic labels from the platform labeler plugin are only be applied when the agent becomes online and then it takes a moment until the labels get applied. So as you already noticed the assignment might be too late when the tool installation is done right at the beginning of the pipeline.
Sometimes I've seen that Jenkins takes quite a while (~ 20-30s) until a node appeared in a label in the UI after adding the label to the node.