提交 65bc0fb1 编写于 作者: K Kohsuke Kawaguchi

Added a convenience method.

Reference: https://trello.com/c/doFFMdUm/46-filepath-getcomputer
上级 0b260dad
...@@ -30,6 +30,7 @@ import com.jcraft.jzlib.GZIPOutputStream; ...@@ -30,6 +30,7 @@ import com.jcraft.jzlib.GZIPOutputStream;
import hudson.Launcher.LocalLauncher; import hudson.Launcher.LocalLauncher;
import hudson.Launcher.RemoteLauncher; import hudson.Launcher.RemoteLauncher;
import hudson.model.AbstractProject; import hudson.model.AbstractProject;
import hudson.model.Computer;
import hudson.model.Item; import hudson.model.Item;
import hudson.model.TaskListener; import hudson.model.TaskListener;
import hudson.org.apache.tools.tar.TarInputStream; import hudson.org.apache.tools.tar.TarInputStream;
...@@ -69,6 +70,7 @@ import org.apache.tools.zip.ZipEntry; ...@@ -69,6 +70,7 @@ import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile; import org.apache.tools.zip.ZipFile;
import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.Stapler;
import javax.annotation.CheckForNull;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
...@@ -1056,6 +1058,22 @@ public final class FilePath implements Serializable { ...@@ -1056,6 +1058,22 @@ public final class FilePath implements Serializable {
return VirtualFile.forFilePath(this); return VirtualFile.forFilePath(this);
} }
/**
* If this {@link FilePath} represents a file on a particular {@link Computer}, return it.
* Otherwise null.
*/
public @CheckForNull Computer toComputer() {
Jenkins j = Jenkins.getInstance();
if (j != null) {
for (Computer c : j.getComputers()) {
if (getChannel()==c.getChannel()) {
return c;
}
}
}
return null;
}
/** /**
* Creates this directory. * Creates this directory.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册