Skip to content

Commit

Permalink
fixed slaves labels/individual nodes list description display null
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Mamh-Linux committed Jul 10, 2019
1 parent 28577bf commit 1b0cea8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/hudson/matrix/LabelAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -75,11 +79,26 @@ private String jsstr(String body, Object... args) {
}

public String buildLabelCheckBox(LabelAtom la, LabelAxis instance) {
String desc = "";
Set<Node> 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("<input type='checkbox' name='values' json='%s' ",
Functions.htmlAttributeEscape(la.getName()))
+String.format("+has(%s)+",jsstr(la.getName()))
+jsstr("/><label class='attach-previous'>%s (%s)</label>",
la.getName(),la.getDescription());
la.getName(),desc);
// '${h.jsStringEscape('<input type="checkbox" name="values" json="'+h.htmlAttributeEscape(l.name)+'" ')}'+has("${h.jsStringEscape(l.name)}")+'${h.jsStringEscape('/><label class="attach-previous">'+l.name+' ('+l.description+')</label>')}'
}
}
Expand Down

0 comments on commit 1b0cea8

Please sign in to comment.