summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Chavez <timothy.chavez@hp.com>2015-08-20 00:14:19 -0500
committerTimothy Chavez <timothy.chavez@hp.com>2015-08-25 16:37:07 -0500
commit2f10c6a06f3f60da632b78387d7933c1b72ab153 (patch)
tree20d960b9f09acef7959ebfb9f482ff2213179769
parent08e9c429de050d0e6ac777579aa901552d27f7ba (diff)
Send node labels back on build completion0.1.3
Zuul will not necessarily know which node type the job it dispatches to Jenkins will run on, so we send that information back to Zuul on build completion so it can use it to submit metrics in that context. Change-Id: Ibca938fcf8a65facd7e39dab4eb994dfc637722a
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Verified+2: Jenkins Code-Review+2: Jeremy Stanley <fungi@yuggoth.org> Workflow+1: Jeremy Stanley <fungi@yuggoth.org> Code-Review+2: yolanda.robla <info@ysoft.biz> Code-Review+2: Khai Do <zaro0508@gmail.com> Code-Review+1: Timothy R. Chavez <timrchavez@gmail.com> Submitted-by: Jenkins Submitted-at: Tue, 06 Oct 2015 17:51:02 +0000 Reviewed-on: https://review.openstack.org/205097 Project: openstack-infra/gearman-plugin Branch: refs/heads/master
-rw-r--r--src/main/java/hudson/plugins/gearman/StartJobWorker.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/hudson/plugins/gearman/StartJobWorker.java b/src/main/java/hudson/plugins/gearman/StartJobWorker.java
index ecc0f0b..33bfd83 100644
--- a/src/main/java/hudson/plugins/gearman/StartJobWorker.java
+++ b/src/main/java/hudson/plugins/gearman/StartJobWorker.java
@@ -28,6 +28,8 @@ import hudson.model.Cause;
28import hudson.model.Computer; 28import hudson.model.Computer;
29import hudson.model.Hudson; 29import hudson.model.Hudson;
30import hudson.model.Queue; 30import hudson.model.Queue;
31import hudson.model.labels.LabelAtom;
32import hudson.model.Node;
31import hudson.model.TextParameterValue; 33import hudson.model.TextParameterValue;
32import hudson.model.queue.QueueTaskFuture; 34import hudson.model.queue.QueueTaskFuture;
33import hudson.slaves.OfflineCause; 35import hudson.slaves.OfflineCause;
@@ -37,6 +39,7 @@ import java.util.Date;
37import java.util.HashMap; 39import java.util.HashMap;
38import java.util.List; 40import java.util.List;
39import java.util.Map; 41import java.util.Map;
42import java.util.Set;
40import java.util.concurrent.TimeUnit; 43import java.util.concurrent.TimeUnit;
41import java.util.concurrent.TimeoutException; 44import java.util.concurrent.TimeoutException;
42 45
@@ -99,6 +102,18 @@ public class StartJobWorker extends AbstractGearmanFunction {
99 if (result != null) { 102 if (result != null) {
100 data.put("result", result.toString()); 103 data.put("result", result.toString());
101 } 104 }
105
106 ArrayList<String> nodeLabels = new ArrayList<String>();
107 Node node = build.getBuiltOn();
108 if (node != null) {
109 Set<LabelAtom> nodeLabelAtoms = node.getAssignedLabels();
110 for (LabelAtom labelAtom : nodeLabelAtoms) {
111 nodeLabels.add(labelAtom.getDisplayName());
112 }
113 }
114 data.put("node_labels", nodeLabels);
115 data.put("node_name", node.getNodeName());
116
102 Gson gson = new Gson(); 117 Gson gson = new Gson();
103 return gson.toJson(data); 118 return gson.toJson(data);
104 } 119 }