本文整理汇总了Java中hudson.FilePath.FileCallable类的典型用法代码示例。如果您正苦于以下问题:Java FileCallable类的具体用法?Java FileCallable怎么用?Java FileCallable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileCallable类属于hudson.FilePath包,在下文中一共展示了FileCallable类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillFilenameLoadSessionItems
import hudson.FilePath.FileCallable; //导入依赖的package包/类
/**
* List model to choose the ZAP session to use. It's called on the remote machine (if present)
* to load all session files in the build's workspace.
*
* @return a {@link ListBoxModel}. It can be empty if the workspace doesn't contain any ZAP sessions.
* @throws InterruptedException
* @throws IOException
*/
public ListBoxModel doFillFilenameLoadSessionItems() throws IOException, InterruptedException {
ListBoxModel items = new ListBoxModel();
// No workspace before the first build, so workspace is null
if(workspace != null) {
Collection<String> sessionsInString = workspace.act(new FileCallable<Collection<String>>() {
private static final long serialVersionUID = 1328740269013881941L;
public Collection<String> invoke(File f, VirtualChannel channel) {
// List all files with FILE_SESSION_EXTENSION on the machine where the workspace is located
Collection<File> colFiles = FileUtils.listFiles(f,
FileFilterUtils.suffixFileFilter(FILE_SESSION_EXTENSION),
TrueFileFilter.INSTANCE);
Collection<String> colString = new ArrayList<String>();
// "Transform" File into String
for (File file : colFiles) {
colString.add(file.getAbsolutePath());
// The following line is to remove the full path to the workspace,
// keep just the relative path to the session
//colString.add(file.getAbsolutePath().replace(workspace.getRemote() + File.separatorChar, ""));
}
return colString;
}
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
// Nothing to do
}
});
items.add(""); // To not load a session, add a blank choice
for (String s : sessionsInString) {
items.add(s);
}
}
return items;
}