本文整理了Java中hudson.FilePath.toComputer()
方法的一些代码示例,展示了FilePath.toComputer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.toComputer()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:toComputer
[英]If this FilePath represents a file on a particular Computer, return it. Otherwise null.
[中]如果此文件路径表示特定计算机上的文件,请返回它。否则为空。
代码示例来源:origin: jenkinsci/jenkins
/**
* Serves the workspace files.
*/
public DirectoryBrowserSupport doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
checkPermission(Item.WORKSPACE);
FilePath ws = getSomeWorkspace();
if ((ws == null) || (!ws.exists())) {
// if there's no workspace, report a nice error message
// Would be good if when asked for *plain*, do something else!
// (E.g. return 404, or send empty doc.)
// Not critical; client can just check if content type is not text/plain,
// which also serves to detect old versions of Hudson.
req.getView(this,"noWorkspace.jelly").forward(req,rsp);
return null;
} else {
Computer c = ws.toComputer();
String title;
if (c == null) {
title = Messages.AbstractProject_WorkspaceTitle(getDisplayName());
} else {
title = Messages.AbstractProject_WorkspaceTitleOnComputer(getDisplayName(), c.getDisplayName());
}
return new DirectoryBrowserSupport(this, ws, title, "folder.png", true);
}
}
代码示例来源:origin: jenkinsci/warnings-ng-plugin
private String getComputerName(final FilePath workspace) {
Computer computer = workspace.toComputer();
if (computer != null) {
return computer.getName();
}
return StringUtils.EMPTY;
}
代码示例来源:origin: jenkinsci/mesos-plugin
@Override
public void tearDown(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException {
Computer computer = workspace.toComputer();
if (computer == null) {
throw new IllegalStateException("Computer is null");
}
if (MesosComputer.class.isInstance(computer)) {
String msg = "Taking single-use slave " + computer.getName() + " offline.";
LOGGER.warning(msg);
listener.getLogger().println(msg);
computer.setTemporarilyOffline(true, OfflineCause.create(Messages._MesosSingleUseSlave_OfflineCause()));
} else {
listener.getLogger().println("Not a single-use slave, this is a " + computer.getClass());
}
}
}
代码示例来源:origin: SonarSource/sonar-scanner-jenkins
@CheckForNull
public static <T extends ToolInstallation & EnvironmentSpecific<T> & NodeSpecific<T>> T getBuildTool(@Nullable T tool, EnvVars env, TaskListener listener, FilePath workspace)
throws IOException,
InterruptedException {
Computer computer = workspace.toComputer();
if (computer == null) {
return null;
}
Node node = computer.getNode();
if (tool == null || node == null) {
return null;
}
T t = tool.forNode(node, listener);
t = t.forEnvironment(env);
return t;
}
代码示例来源:origin: SonarSource/sonar-scanner-jenkins
private void computeJdkToUse(Run<?, ?> build, FilePath workspace, TaskListener listener, EnvVars env) throws IOException, InterruptedException {
JDK jdkToUse = getJdkToUse(getProject(build));
if (jdkToUse != null) {
Computer computer = workspace.toComputer();
// just in case we are not in a build
if (computer != null) {
jdkToUse = jdkToUse.forNode(computer.getNode(), listener);
}
jdkToUse.buildEnvVars(env);
}
}
代码示例来源:origin: jenkinsci/coverity-plugin
final Computer computer = workspace.toComputer();
if (computer == null) {
throw new AbortException("Cannot get Coverity tools installation");
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Serves the workspace files.
*/
public DirectoryBrowserSupport doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
checkPermission(Item.WORKSPACE);
FilePath ws = getSomeWorkspace();
if ((ws == null) || (!ws.exists())) {
// if there's no workspace, report a nice error message
// Would be good if when asked for *plain*, do something else!
// (E.g. return 404, or send empty doc.)
// Not critical; client can just check if content type is not text/plain,
// which also serves to detect old versions of Hudson.
req.getView(this,"noWorkspace.jelly").forward(req,rsp);
return null;
} else {
Computer c = ws.toComputer();
String title;
if (c == null) {
title = Messages.AbstractProject_WorkspaceTitle(getDisplayName());
} else {
title = Messages.AbstractProject_WorkspaceTitleOnComputer(getDisplayName(), c.getDisplayName());
}
return new DirectoryBrowserSupport(this, ws, title, "folder.png", true);
}
}
代码示例来源:origin: jenkinsci/nodejs-plugin
throw new IOException(Messages.NodeJSBuilders_noInstallationFound(nodeJSInstallationName));
Computer computer = workspace.toComputer();
if (computer == null) {
throw new AbortException(Messages.NodeJSBuilders_nodeOffline());
代码示例来源:origin: jenkinsci/tfs-plugin
Server server = createServer(launcher, listener, build);
try {
WorkspaceConfiguration workspaceConfiguration = new WorkspaceConfiguration(server.getUrl(), getWorkspaceName(build, workspaceFilePath.toComputer()), getProjectPath(build), getCloakedPaths(build), getLocalPath());
final Run<?, ?> previousBuild = build.getPreviousBuild();
Computer computer = workspaceFilePath.toComputer();
if (computer != null) {
BuildWorkspaceConfiguration nodeConfiguration = new BuildWorkspaceConfigurationRetriever().getLatestForNode(computer.getNode(), previousBuild);
内容来源于网络,如有侵权,请联系作者删除!