本文介绍了如何将数据从FileCallable发送到记录器,再通过Jenkins插件发送给主服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此处中的以下示例:
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;
}
}
Freshen类将被序列化并发送到从站以执行.我如何从Freshen类内部访问并记录主记录器上的记录器进度?
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?
推荐答案
我参加聚会有点晚了,但是我偶然发现了同一个问题,并通过将TaskListener
传递给FileCallable
来解决了这个问题:
I am a bit late to the party, but I just stumbled upon the same problem and solved it by passing the TaskListener
to the FileCallable
:
private static final class Freshen implements FileCallable<Void> {
private static final long serialVersionUID = 1;
private final TaskListener listener;
public Freshen(TaskListener listener) {
this.listener = listener;
}
@Override public Void invoke(File f, VirtualChannel channel) {
RemoteOutputStream ros = new RemoteOutputStream(listener.getLogger());
ros.write("hello there".getBytes(StandardCharsets.UTF_8));
return null;
}
}
这篇关于如何将数据从FileCallable发送到记录器,再通过Jenkins插件发送给主服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!