diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index d5028c4b34..9a70ecb163 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -701,6 +701,22 @@ public final class FilePath implements Serializable { }); } + /** + * Rename this file/directory to the target filepath. This FilePath and the target must + * be on the some host + */ + public void renameTo(final FilePath target) throws IOException, InterruptedException { + if(this.channel != target.channel) { + throw new IOException("renameTo target must be on the same host"); + } + act(new FileCallable() { + public Void invoke(File f, VirtualChannel channel) throws IOException { + f.renameTo(new File(target.remote)); + return null; + } + }); + } + /** * Copies this file to the specified target. */