From e1f3ca89be5885b0c876db0350f17c0886542210 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 4 Nov 2021 17:55:31 +0100 Subject: [PATCH 1/7] Make trim labels more selective when we're operating on selected nodes --- core/src/main/java/jenkins/model/Jenkins.java | 21 +++++++++++++++++++ core/src/main/java/jenkins/model/Nodes.java | 13 +++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index b6303b377a9f..a22f7efb3303 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -2251,6 +2251,27 @@ public DescribableList, NodePropertyDescriptor> getGlobalNodePro } } + /** + * Reset labels and remove invalid ones for the given nodes. + * @param nodes the nodes taken as reference to update labels + */ + void trimLabels(Node... nodes) { + Set includedLabels = new HashSet<>(); + for (Node n : nodes) { + includedLabels.addAll(n.getAssignedLabels()); + } + Set