Skip to content

Commit

Permalink
[FIXED JENKINS-14120] fix confusing output
Browse files Browse the repository at this point in the history
  • Loading branch information
imod committed Jun 24, 2012
1 parent eae0db0 commit 95366bb
Showing 1 changed file with 15 additions and 1 deletion.
@@ -1,9 +1,15 @@
package org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger;

import static com.google.common.collect.Lists.transform;

import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import hudson.EnvVars;
import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.model.TaskListener;
Expand All @@ -14,6 +20,7 @@
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

Expand All @@ -24,6 +31,12 @@ public class AllNodesForLabelBuildParameterFactory extends AbstractBuildParamete
public final String name;
public final String nodeLabel;

private static final Function<Node, String> PROJECT_NAME_FUNCTION = new Function<Node, String>() {
public String apply(Node from) {
return from.getDisplayName();
}
};

@DataBoundConstructor
public AllNodesForLabelBuildParameterFactory(String name, String nodeLabel) {
this.name = name;
Expand All @@ -37,7 +50,8 @@ public List<AbstractBuildParameters> getParameters(AbstractBuild<?, ?> build, Ta

listener.getLogger().println("Getting all nodes with label: " + labelExpanded);
Set<Node> nodes = Hudson.getInstance().getLabel(labelExpanded).getNodes();
listener.getLogger().println("Found nodes: " + String.valueOf(nodes));
List<String> nodeNames = Lists.transform(new ArrayList<Node>(nodes), PROJECT_NAME_FUNCTION);
listener.getLogger().println("Found nodes: " + String.valueOf(nodeNames));
List<AbstractBuildParameters> params = Lists.newArrayList();
if (nodes == null || nodes.isEmpty()) {
params.add(new NodeLabelBuildParameter(name, labelExpanded));
Expand Down

0 comments on commit 95366bb

Please sign in to comment.