mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-28 20:15:22 +00:00
Added a convenience method.
Reference: https://trello.com/c/doFFMdUm/46-filepath-getcomputer
This commit is contained in:
1 parent
0b260dad8c
commit
65bc0fb146
1 file changed
+18
@@ -30,6 +30,7 @@ import com.jcraft.jzlib.GZIPOutputStream;
|
||||
import hudson.Launcher.LocalLauncher;
|
||||
import hudson.Launcher.RemoteLauncher;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.org.apache.tools.tar.TarInputStream;
|
||||
@@ -69,6 +70,7 @@ import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -1056,6 +1058,22 @@ public final class FilePath implements Serializable {
|
||||
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.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user