Send node label with data status packet

Zuul can use this information to organize its build data by node type.
This will give us more granular insights into load and capacity.

Change-Id: Ibca938fcf8a65facd7e39dab4eb994dfc637722a
This commit is contained in:
Timothy Chavez 2015-08-20 00:14:19 -05:00
parent 08e9c429de
commit ce08a41f01
1 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,8 @@ import hudson.model.Cause;
import hudson.model.Computer;
import hudson.model.Hudson;
import hudson.model.Queue;
import hudson.model.labels.LabelAtom;
import hudson.model.Node;
import hudson.model.TextParameterValue;
import hudson.model.queue.QueueTaskFuture;
import hudson.slaves.OfflineCause;
@ -99,6 +101,17 @@ public class StartJobWorker extends AbstractGearmanFunction {
if (result != null) {
data.put("result", result.toString());
}
ArrayList<String> nodeLabels = new ArrayList<String>();
Node node = build.getBuiltOn();
if ( node != null ) {
Set<LabelAtom> nodeLabelAtoms = node.getAssignedLabels();
for (LabelAtom labelAtom : nodeLabelAtoms) {
nodeLabels.add(labelAtom.getDisplayName());
}
}
data.put("node_labels", nodeLabels);
Gson gson = new Gson();
return gson.toJson(data);
}