From ab1816c13cd7ec7c3f2d5bef18bef28d78cbd666 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Fri, 25 Jul 2008 17:29:36 +0000 Subject: [PATCH] see discussion in http://www.nabble.com/Getting-the-name-of-the-node-td18649119.html git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11020 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Launcher.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index ad6ae673c1..9d33d6ce89 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -64,6 +64,25 @@ public abstract class Launcher { return channel; } + /** + * If this {@link Launcher} is encapsulating an execution on a specific {@link Computer}, + * return it. + * + *

+ * Because of the way internal Hudson abstractions are set up (that is, {@link Launcher} only + * needs a {@link VirtualChannel} to do its job and isn't really required that the channel + * comes from an existing {@link Computer}), this method may not always the right {@link Computer} instance. + * + * @return + * null if this launcher is not created from a {@link Computer} object. + */ + public Computer getComputer() { + for( Computer c : Hudson.getInstance().getComputers() ) + if(c.getChannel()==channel) + return c; + return null; + } + public final Proc launch(String cmd, Map env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); } -- GitLab