summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README.rst2
-rwxr-xr-xbuild-fast3
-rw-r--r--pom.xml24
-rw-r--r--src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java1
-rw-r--r--src/main/java/hudson/plugins/gearman/StartJobWorker.java19
-rw-r--r--version-properties.sh32
7 files changed, 55 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index 59a8a93..f6d0d6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1/target 1/target
2/version.properties
2/work 3/work
3/.config 4/.config
diff --git a/README.rst b/README.rst
index cb73caf..0b6e094 100644
--- a/README.rst
+++ b/README.rst
@@ -33,7 +33,7 @@ Bugs should be filed on StoryBoard, not GitHub:
33 33
34Cloning: 34Cloning:
35 35
36 * https://github.com/openstack-infra/gearman-plugin.git 36 * https://git.openstack.org/openstack-infra/gearman-plugin
37 37
38 38
39License 39License
diff --git a/build-fast b/build-fast
new file mode 100755
index 0000000..240d68b
--- /dev/null
+++ b/build-fast
@@ -0,0 +1,3 @@
1#!/bin/bash -eux
2. version-properties.sh
3mvn -Dproject-version="$PROJECT_VER" -DskipTests=true clean package
diff --git a/pom.xml b/pom.xml
index 2f34cbc..0cf01c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,12 +55,6 @@
55 </developer> 55 </developer>
56 </developers> 56 </developers>
57 57
58 <scm>
59 <connection>scm:git:ssh://github.com/openstack-infra/gearman-plugin.git</connection>
60 <developerConnection>scm:git:ssh://git@github.com/openstack-infra/gearman-plugin.git</developerConnection>
61 <url>https://github.com/openstack-infra/gearman-plugin</url>
62 </scm>
63
64 <repositories> 58 <repositories>
65 <repository> 59 <repository>
66 <id>repo.jenkins-ci.org</id> 60 <id>repo.jenkins-ci.org</id>
@@ -148,23 +142,6 @@
148 </properties> 142 </properties>
149 143
150 <build> 144 <build>
151 <extensions>
152 <extension>
153 <groupId>org.apache.maven.scm</groupId>
154 <artifactId>maven-scm-provider-gitexe</artifactId>
155 <version>1.3</version>
156 </extension>
157 <extension>
158 <groupId>org.apache.maven.scm</groupId>
159 <artifactId>maven-scm-manager-plexus</artifactId>
160 <version>1.3</version>
161 </extension>
162 <extension>
163 <groupId>org.kathrynhuxtable.maven.wagon</groupId>
164 <artifactId>wagon-gitsite</artifactId>
165 <version>0.3.1</version>
166 </extension>
167 </extensions>
168 <pluginManagement> 145 <pluginManagement>
169 <plugins> 146 <plugins>
170 <plugin> 147 <plugin>
@@ -299,7 +276,6 @@
299 <report>license</report> 276 <report>license</report>
300 <report>mailing-list</report> 277 <report>mailing-list</report>
301 <report>project-team</report> 278 <report>project-team</report>
302 <report>scm</report>
303 <report>summary</report> 279 <report>summary</report>
304 </reports> 280 </reports>
305 </reportSet> 281 </reportSet>
diff --git a/src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java b/src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java
index 798861e..6200369 100644
--- a/src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java
+++ b/src/main/java/hudson/plugins/gearman/MyGearmanWorkerImpl.java
@@ -613,6 +613,7 @@ public class MyGearmanWorkerImpl implements GearmanSessionEventHandler {
613 new GearmanPacketImpl(GearmanPacketMagic.REQ, 613 new GearmanPacketImpl(GearmanPacketMagic.REQ,
614 GearmanPacketType.WORK_FAIL, handle)); 614 GearmanPacketType.WORK_FAIL, handle));
615 session.submitTask(gsr); 615 session.submitTask(gsr);
616 availability.unlock(this);
616 enqueueNoopEvent(); 617 enqueueNoopEvent();
617 } else { 618 } else {
618 GearmanFunction function = def.getFactory().getFunction(); 619 GearmanFunction function = def.getFactory().getFunction();
diff --git a/src/main/java/hudson/plugins/gearman/StartJobWorker.java b/src/main/java/hudson/plugins/gearman/StartJobWorker.java
index bd0e7a7..33bfd83 100644
--- a/src/main/java/hudson/plugins/gearman/StartJobWorker.java
+++ b/src/main/java/hudson/plugins/gearman/StartJobWorker.java
@@ -28,7 +28,9 @@ 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.StringParameterValue; 31import hudson.model.labels.LabelAtom;
32import hudson.model.Node;
33import hudson.model.TextParameterValue;
32import hudson.model.queue.QueueTaskFuture; 34import hudson.model.queue.QueueTaskFuture;
33import hudson.slaves.OfflineCause; 35import hudson.slaves.OfflineCause;
34 36
@@ -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 }
@@ -141,7 +156,7 @@ public class StartJobWorker extends AbstractGearmanFunction {
141 }.getType()); 156 }.getType());
142 // set build parameters that were passed in from client 157 // set build parameters that were passed in from client
143 for (Map.Entry<String, String> entry : inParams.entrySet()) { 158 for (Map.Entry<String, String> entry : inParams.entrySet()) {
144 buildParams.add(new StringParameterValue(entry.getKey(), entry.getValue())); 159 buildParams.add(new TextParameterValue(entry.getKey(), entry.getValue()));
145 } 160 }
146 String offline = inParams.get("OFFLINE_NODE_WHEN_COMPLETE"); 161 String offline = inParams.get("OFFLINE_NODE_WHEN_COMPLETE");
147 if (offline != null) { 162 if (offline != null) {
diff --git a/version-properties.sh b/version-properties.sh
new file mode 100644
index 0000000..584b352
--- /dev/null
+++ b/version-properties.sh
@@ -0,0 +1,32 @@
1#!/bin/bash -ex
2#
3# This is a script that helps us version build artifacts. It retrieves
4# git info and generates version strings.
5#
6# Source:
7# http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins/scripts/version-properties.sh
8#
9
10# get version info from scm
11SCM_TAG=$(git describe --abbrev=0 --tags) || true
12SCM_SHA=$(git rev-parse --short HEAD) || true
13
14# assumes format is like this '0.0.4-2-g135721c'
15COMMITS_SINCE_TAG=$(git describe | awk '{split($0,a,"-"); print a[2]}') || true
16
17# just use git sha if there is no tag yet.
18if [[ "${SCM_TAG}" == "" ]]; then
19 SCM_TAG=$SCM_SHA
20fi
21
22# General build version should be something like '0.0.4.3.d4ee90c'
23# Release build version should be something like '0.0.5'
24if [[ "${COMMITS_SINCE_TAG}" == "" ]]; then
25 PROJECT_VER=$SCM_TAG
26else
27 PROJECT_VER="$SCM_TAG.$COMMITS_SINCE_TAG.$SCM_SHA";
28fi
29
30echo "SCM_SHA=$SCM_SHA" >version.properties
31echo "PROJECT_VER=$PROJECT_VER" >>version.properties
32echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>version.properties