Skip to content
Permalink
Browse files
Merge branch 'JENKINS-21999' of github.com:christ66/jenkins
  • Loading branch information
jglick committed Apr 3, 2014
2 parents 44a8ec1 + eabd1ba commit e7c7bbd541d091923fceb6a2613881944ae8c810
Showing 2 changed files with 39 additions and 1 deletion.
@@ -39,6 +39,8 @@
import hudson.util.ArgumentListBuilder;
import hudson.util.ProcessTree;
import org.apache.commons.io.input.NullInputStream;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import java.io.BufferedOutputStream;
import java.io.File;
@@ -841,6 +843,30 @@ public synchronized void close() throws IOException {
}
}

@Restricted(NoExternalUse.class)
public static class DummyLauncher extends Launcher {

public DummyLauncher(TaskListener listener) {
super(listener, null);
}

@Override
public Proc launch(ProcStarter starter) throws IOException {
throw new IOException("Can not call launch on a dummy launcher.");
}

@Override
public Channel launchChannel(String[] cmd, OutputStream out, FilePath workDir, Map<String, String> envVars) throws IOException, InterruptedException {
throw new IOException("Can not call launchChannel on a dummy launcher.");
}

@Override
public void kill(Map<String, String> modelEnvVars) throws IOException, InterruptedException {
// Kill method should do nothing.
}
}


/**
* Launches processes remotely by using the given channel.
*/
@@ -343,9 +343,21 @@ public byte[] readFully() throws IOException {

}

/**
* Creates a launcher for the slave.
*
* @return
* If there is no computer it will return a {@link hudson.Launcher.DummyLauncher}, otherwise it
* will return a {@link hudson.Launcher.RemoteLauncher} instead.
*/
public Launcher createLauncher(TaskListener listener) {
SlaveComputer c = getComputer();
return new RemoteLauncher(listener, c.getChannel(), c.isUnix()).decorateFor(this);
if (c == null) {
listener.error("Issue with creating launcher for slave " + name + ".");
return new Launcher.DummyLauncher(listener);
} else {
return new RemoteLauncher(listener, c.getChannel(), c.isUnix()).decorateFor(this);
}
}

/**

0 comments on commit e7c7bbd

Please sign in to comment.