summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <dims@linux.vnet.ibm.com>2014-01-17 10:31:57 -0500
committerDavanum Srinivas <dims@linux.vnet.ibm.com>2014-01-24 09:55:37 -0500
commit7e2ca62e1c078061ffd620e46cb095f31c31420c (patch)
tree40ae855a17a9c50f41780cc4baf92980ff9d8fbd
parent36ca349ad10c3f17e69a70c73fefcb2ae3405ca7 (diff)
Include Jenkins host name / Code cleanup
The first cut of this review was to inject the jenkins/build master host name and was then expanded to the following * Use Jenkins class as Hudson class is being deprecated * Change instances of Hudson currently named hudson to jenkins * Remove unused imports * Remove extra semi-colons Change-Id: If1715b574952ac4c228501459663956fee55c4a6
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Verified+2: Jenkins Approved+1: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Submitted-by: Jenkins Submitted-at: Mon, 27 Jan 2014 23:01:47 +0000 Reviewed-on: https://review.openstack.org/67495 Project: openstack-infra/zmq-event-publisher Branch: refs/heads/master
-rw-r--r--src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java7
-rw-r--r--src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java17
-rw-r--r--src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java8
-rw-r--r--src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java10
4 files changed, 22 insertions, 20 deletions
diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java
index a9794c5..b3e347e 100644
--- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java
+++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java
@@ -21,17 +21,10 @@ import hudson.model.Job;
21import hudson.model.JobProperty; 21import hudson.model.JobProperty;
22import hudson.model.JobPropertyDescriptor; 22import hudson.model.JobPropertyDescriptor;
23import hudson.model.AbstractProject; 23import hudson.model.AbstractProject;
24import hudson.util.FormValidation;
25 24
26import java.util.ArrayList;
27import java.util.List;
28
29import net.sf.json.JSON;
30import net.sf.json.JSONArray;
31import net.sf.json.JSONObject; 25import net.sf.json.JSONObject;
32 26
33import org.kohsuke.stapler.DataBoundConstructor; 27import org.kohsuke.stapler.DataBoundConstructor;
34import org.kohsuke.stapler.QueryParameter;
35import org.kohsuke.stapler.StaplerRequest; 28import org.kohsuke.stapler.StaplerRequest;
36 29
37public class HudsonNotificationProperty extends 30public class HudsonNotificationProperty extends
diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java
index bddf36e..cfce93f 100644
--- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java
+++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java
@@ -18,7 +18,6 @@ package org.jenkinsci.plugins.ZMQEventPublisher;
18 18
19import hudson.EnvVars; 19import hudson.EnvVars;
20import hudson.model.AbstractBuild; 20import hudson.model.AbstractBuild;
21import hudson.model.Hudson;
22import hudson.model.Job; 21import hudson.model.Job;
23import hudson.model.ParameterValue; 22import hudson.model.ParameterValue;
24import hudson.model.ParametersAction; 23import hudson.model.ParametersAction;
@@ -26,28 +25,26 @@ import hudson.model.Run;
26import hudson.model.Executor; 25import hudson.model.Executor;
27import hudson.model.Computer; 26import hudson.model.Computer;
28import hudson.model.TaskListener; 27import hudson.model.TaskListener;
29 28import jenkins.model.Jenkins;
30import java.io.IOException;
31import java.util.List;
32 29
33import com.google.gson.FieldNamingPolicy; 30import com.google.gson.FieldNamingPolicy;
34import com.google.gson.Gson; 31import com.google.gson.Gson;
35import com.google.gson.GsonBuilder; 32import com.google.gson.GsonBuilder;
36 33
37import org.jenkinsci.plugins.ZMQEventPublisher.model.BuildState;; 34import org.jenkinsci.plugins.ZMQEventPublisher.model.BuildState;
38import org.jenkinsci.plugins.ZMQEventPublisher.model.JobState;; 35import org.jenkinsci.plugins.ZMQEventPublisher.model.JobState;
39 36
40public enum Phase { 37public enum Phase {
41 STARTED, COMPLETED, FINISHED; 38 STARTED, COMPLETED, FINISHED;
42 39
43 @SuppressWarnings({ "unchecked", "rawtypes" }) 40 @SuppressWarnings({ "unchecked", "rawtypes" })
44 public String handlePhase(Run run, String status, TaskListener listener) { 41 public String handlePhase(Run run, String status, TaskListener listener) {
45 Hudson hudson = Hudson.getInstance(); 42 Jenkins jenkins = Jenkins.getInstance();
46 HudsonNotificationProperty property = (HudsonNotificationProperty) 43 HudsonNotificationProperty property = (HudsonNotificationProperty)
47 run.getParent().getProperty(HudsonNotificationProperty.class); 44 run.getParent().getProperty(HudsonNotificationProperty.class);
48 HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = 45 HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty =
49 (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) 46 (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor)
50 hudson.getDescriptor(HudsonNotificationProperty.class); 47 jenkins.getDescriptor(HudsonNotificationProperty.class);
51 if ((property != null && property.isEnabled()) || 48 if ((property != null && property.isEnabled()) ||
52 (globalProperty != null && globalProperty.isGloballyEnabled())) { 49 (globalProperty != null && globalProperty.isGloballyEnabled())) {
53 return buildMessage(run.getParent(), run, status); 50 return buildMessage(run.getParent(), run, status);
@@ -68,7 +65,8 @@ public enum Phase {
68 buildState.setPhase(this); 65 buildState.setPhase(this);
69 buildState.setStatus(status); 66 buildState.setStatus(status);
70 67
71 String rootUrl = Hudson.getInstance().getRootUrl(); 68 Jenkins jenkins = Jenkins.getInstance();
69 String rootUrl = jenkins.getRootUrl();
72 if (rootUrl != null) { 70 if (rootUrl != null) {
73 buildState.setFullUrl(rootUrl + run.getUrl()); 71 buildState.setFullUrl(rootUrl + run.getUrl());
74 } 72 }
@@ -78,6 +76,7 @@ public enum Phase {
78 Computer computer = executor.getOwner(); 76 Computer computer = executor.getOwner();
79 if (computer != null) { 77 if (computer != null) {
80 buildState.setNodeName(computer.getName()); 78 buildState.setNodeName(computer.getName());
79 buildState.setHostName(jenkins.getDisplayName());
81 } 80 }
82 } 81 }
83 82
diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java
index 9cfe64d..588c8d0 100644
--- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java
+++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java
@@ -16,7 +16,7 @@
16 16
17package org.jenkinsci.plugins.ZMQEventPublisher; 17package org.jenkinsci.plugins.ZMQEventPublisher;
18 18
19import hudson.model.Hudson; 19import jenkins.model.Jenkins;
20 20
21import java.util.concurrent.LinkedBlockingQueue; 21import java.util.concurrent.LinkedBlockingQueue;
22import java.util.logging.Level; 22import java.util.logging.Level;
@@ -42,10 +42,10 @@ public class ZMQRunnable implements Runnable {
42 } 42 }
43 43
44 private int getPort() { 44 private int getPort() {
45 Hudson hudson = Hudson.getInstance(); 45 Jenkins jenkins = Jenkins.getInstance();
46 HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = 46 HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty =
47 (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) 47 (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor)
48 hudson.getDescriptor(HudsonNotificationProperty.class); 48 jenkins.getDescriptor(HudsonNotificationProperty.class);
49 if (globalProperty != null) { 49 if (globalProperty != null) {
50 return globalProperty.getPort(); 50 return globalProperty.getPort();
51 } 51 }
@@ -92,7 +92,7 @@ public class ZMQRunnable implements Runnable {
92 String event; 92 String event;
93 while(true) { 93 while(true) {
94 try { 94 try {
95 event = queue.take();; 95 event = queue.take();
96 bindSocket(); 96 bindSocket();
97 if (publisher != null) { 97 if (publisher != null) {
98 try { 98 try {
diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java
index 68ca339..4253af0 100644
--- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java
+++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java
@@ -36,6 +36,8 @@ public class BuildState {
36 36
37 private String nodeName; 37 private String nodeName;
38 38
39 private String hostName;
40
39 public int getNumber() { 41 public int getNumber() {
40 return number; 42 return number;
41 } 43 }
@@ -91,4 +93,12 @@ public class BuildState {
91 public void setNodeName(String nodeName) { 93 public void setNodeName(String nodeName) {
92 this.nodeName = nodeName; 94 this.nodeName = nodeName;
93 } 95 }
96
97 public String getHostName() {
98 return hostName;
99 }
100
101 public void setHostName(String hostName) {
102 this.hostName = hostName;
103 }
94} 104}