diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 0cc9403ff0..773405acf2 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -27,6 +27,8 @@ package hudson; import hudson.Launcher.LocalLauncher; import hudson.Launcher.RemoteLauncher; +import hudson.model.AbstractDescribableImpl; +import hudson.model.Descriptor; import jenkins.model.Jenkins; import hudson.model.TaskListener; import hudson.model.AbstractProject; @@ -828,7 +830,13 @@ public final class FilePath implements Serializable { if(channel!=null) { // run this on a remote system try { - return channel.call(new FileCallableWrapper(callable,cl)); + DelegatingCallable wrapper = new FileCallableWrapper(callable, cl); + ExtensionList factories = Jenkins.getInstance().getExtensionList(AroundInvokeFactory.class); + for (AroundInvokeFactory factory : factories) { + wrapper = factory.wrap(wrapper); + } + + return channel.call(wrapper); } catch (TunneledInterruptedException e) { throw (InterruptedException)new InterruptedException().initCause(e); } catch (AbortException e) { @@ -843,6 +851,12 @@ public final class FilePath implements Serializable { } } + public static abstract class AroundInvokeFactory extends AbstractDescribableImpl implements ExtensionPoint { + + public abstract DelegatingCallable wrap(DelegatingCallable callable); + + } + /** * Executes some program on the machine that this {@link FilePath} exists, * so that one can perform local file operations. @@ -2197,6 +2211,7 @@ public final class FilePath implements Serializable { public T call() throws IOException { try { + Channel.current(). return callable.invoke(new File(remote), Channel.current()); } catch (InterruptedException e) { throw new TunneledInterruptedException(e);