Skip to content

Commit

Permalink
Merge branch 'JENKINS-7543' of https://github.com/mrdfuse/swarm-plugin
Browse files Browse the repository at this point in the history
…into JENKINS-7543

Conflicts:
	plugin/src/main/java/hudson/plugins/swarm/PluginImpl.java
  • Loading branch information
mrdfuse committed Oct 1, 2014
2 parents f71039e + d2e14a1 commit 1c7d9d3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
9 changes: 5 additions & 4 deletions client/src/main/java/hudson/plugins/swarm/Client.java
@@ -1,12 +1,13 @@
package hudson.plugins.swarm;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.InetAddress;

import javax.xml.parsers.ParserConfigurationException;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;

/**
* Swarm client.
* <p/>
Expand Down
3 changes: 3 additions & 0 deletions client/src/main/java/hudson/plugins/swarm/Options.java
Expand Up @@ -49,6 +49,9 @@ public class Options {
handler = ModeOptionHandler.class
)
public String mode = ModeOptionHandler.NORMAL;

@Option(name = "-toolLocations", usage = "Whitespace-separated list of tool locations to be defined on this slave. A tool location is specified as 'toolName:location'")
public List<String> toolLocations = new ArrayList<String>();

@Option(name = "-username", usage = "The Jenkins username for authentication")
public String username;
Expand Down
61 changes: 28 additions & 33 deletions client/src/main/java/hudson/plugins/swarm/SwarmClient.java
Expand Up @@ -2,24 +2,7 @@

import hudson.remoting.Launcher;
import hudson.remoting.jnlp.Main;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -45,9 +28,26 @@
import java.util.List;
import java.util.Random;

/**
*
*/
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.lang.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;

public class SwarmClient {

private final Options options;
Expand All @@ -57,7 +57,7 @@ public SwarmClient(Options options) {
}

public Candidate discoverFromBroadcast() throws IOException,
InterruptedException, RetryException, ParserConfigurationException {
RetryException, ParserConfigurationException {

DatagramSocket socket = new DatagramSocket();
socket.setBroadcast(true);
Expand Down Expand Up @@ -273,21 +273,17 @@ protected void createSwarmSlave(Candidate target) throws IOException, Interrupte
// ie. it does not return a 401 (Unauthorized)
// but immediately a 403 (Forbidden)

StringBuilder labelStr = new StringBuilder();
for (String l : options.labels) {
if (labelStr.length() > 0) {
labelStr.append(' ');
}
labelStr.append(l);
}
String labelStr = StringUtils.join(options.labels, ' ');
String toolLocationsStr = StringUtils.join(options.toolLocations, ' ');

PostMethod post = new PostMethod(target.url
+ "/plugin/swarm/createSlave?name=" + options.name + "&executors="
+ options.executors
+ "/plugin/swarm/createSlave?name=" + options.name
+ "&executors=" + options.executors
+ param("remoteFsRoot", options.remoteFsRoot.getAbsolutePath())
+ param("description", options.description)
+ param("labels", labelStr.toString()) + "&secret="
+ target.secret
+ param("labels", labelStr)
+ param("toolLocations", toolLocationsStr)
+ "&secret=" + target.secret
+ param("mode", options.mode.toUpperCase()));

post.setDoAuthentication(true);
Expand All @@ -301,7 +297,6 @@ protected void createSwarmSlave(Candidate target) throws IOException, Interrupte
if (responseCode != 200) {
throw new RetryException(
"Failed to create a slave on Jenkins CODE: " + responseCode);

}
}

Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/java/hudson/plugins/swarm/PluginImpl.java
Expand Up @@ -5,6 +5,7 @@
import hudson.Util;
import hudson.model.Descriptor.FormException;
import hudson.model.Node;
import hudson.slaves.NodeProperty;
import hudson.slaves.SlaveComputer;
import hudson.tools.ToolDescriptor;
import hudson.tools.ToolInstallation;
Expand Down

0 comments on commit 1c7d9d3

Please sign in to comment.