From 1b0cea8d710d075eaaa9c5823417c9c7440a8237 Mon Sep 17 00:00:00 2001 From: Mamh-Linux Date: Wed, 10 Jul 2019 17:19:28 +0800 Subject: [PATCH] fixed slaves labels/individual nodes list description display null in Configuration Matrix add axis/ add slaves: Labels Labels_s2 (null) Labels_windows (this is windows) master_Labels (master_Labels Description) Individual nodes master (null) s1 (null) s2 (null) after fix: Labels Labels_s2 (s2) Labels_windows (this is windows: s2) master_Labels (master_Labels Description: Jenkins, s1) Individual nodes master (the master Jenkins node) s1 (Description s1) s2 (Description s2) Signed-off-by: Mamh-Linux --- src/main/java/hudson/matrix/LabelAxis.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/matrix/LabelAxis.java b/src/main/java/hudson/matrix/LabelAxis.java index de8b6d10..4720ebed 100644 --- a/src/main/java/hudson/matrix/LabelAxis.java +++ b/src/main/java/hudson/matrix/LabelAxis.java @@ -26,11 +26,15 @@ import hudson.Extension; import hudson.Functions; import hudson.Util; +import hudson.model.Node; import jenkins.model.Jenkins; import hudson.model.labels.LabelAtom; + +import org.apache.commons.lang.StringUtils; import org.kohsuke.stapler.DataBoundConstructor; import java.util.List; +import java.util.Set; /** * {@link Axis} that selects label expressions. @@ -75,11 +79,26 @@ private String jsstr(String body, Object... args) { } public String buildLabelCheckBox(LabelAtom la, LabelAxis instance) { + String desc = ""; + Set nodes = la.getNodes(); + if (la.isSelfLabel()) { // if true this is Individual nodes + for (Node node : nodes) {// maybe only one? + desc = node.getNodeDescription(); + } + } else { // false this is Labels + if(la.getDescription() != null){ + desc += la.getDescription()+": "; + } + for (Node node : nodes) { + desc += node.getDisplayName() + ", "; + } + desc = StringUtils.strip(desc, ", "); + } return jsstr("", - la.getName(),la.getDescription()); + la.getName(),desc); // '${h.jsStringEscape('')}' } }