I'm using the following example from here:
void someMethod(FilePath file) {
// make 'file' a fresh empty directory.
file.act(new Freshen());
}
// if 'file' is on a different node, this FileCallable will
// be transferred to that node and executed there.
private static final class Freshen implements FileCallable<Void> {
private static final long serialVersionUID = 1;
@Override public Void invoke(File f, VirtualChannel channel) {
// f and file represent the same thing
f.deleteContents();
f.mkdirs();
return null;
}
}
The Freshen class will be serialized and sent to a slave for execution. How can i get access and log progress to the logger on the master from inside my Freshen class?
No, the execution will be on the slave and FilePath represents a file path on a specific slave or the master. (see documentation)
Try this code to pass the logger to Freshen (untested):
I am a bit late to the party, but I just stumbled upon the same problem and solved it by passing the
TaskListener
to theFileCallable
: