@Override protected FilePath tryResolve() { return FilePathUtils.find(slave, path); } @Override public String toString() {
private FilePathPickle(FilePath v) { slave = FilePathUtils.getNodeName(v); path = v.getRemote(); }
private WorkspaceListLeasePickle(WorkspaceList.Lease lease) { slave = FilePathUtils.getNodeNameOrNull(lease.path); path = lease.path.getRemote(); }
private void onCheckout(SCM scm, FilePath workspace, TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState pollingBaseline) throws Exception { if (changelogFile != null && changelogFile.isFile()) { ChangeLogSet<?> cls = scm.createChangeLogParser().parse(this, scm.getEffectiveBrowser(), changelogFile); if (!cls.isEmptySet()) { getChangeSets().add(cls); } for (SCMListener l : SCMListener.all()) { l.onChangeLogParsed(this, scm, listener, cls); } } checkouts(listener).add(new SCMCheckout(scm, FilePathUtils.getNodeName(workspace), workspace.getRemote(), changelogFile, pollingBaseline)); }
/** Reconstructs the live workspace, if possible. */ public final @CheckForNull FilePath getWorkspace() { return FilePathUtils.find(getNode(), getPath()); }
/** * Same as {@link #getNodeNameOrNull} but throws a diagnostic exception in case of failure. * @param f a file, possible remote * @return a node name ({@code ""} for master), if known * @throws IllegalStateException if the association to a node is unknown */ public static @Nonnull String getNodeName(@Nonnull FilePath f) throws IllegalStateException { String name = getNodeNameOrNull(f); if (name != null) { return name; } else { throw new IllegalStateException("no known slave for " + f + " among " + Listener.getChannelNames()); } }
@Override public boolean start() throws Exception { returnStdout = step.returnStdout; encoding = step.encoding; returnStatus = step.returnStatus; StepContext context = getContext(); ws = context.get(FilePath.class); node = FilePathUtils.getNodeName(ws); DurableTask durableTask = step.task(); if (returnStdout) { durableTask.captureOutput(); } controller = durableTask.launch(context.get(EnvVars.class), ws, context.get(Launcher.class), context.get(TaskListener.class)); this.remote = ws.getRemote(); setupTimer(); return false; }
private @CheckForNull FilePath getWorkspace() throws AbortException { if (ws == null) { ws = FilePathUtils.find(node, remote); if (ws == null) { LOGGER.log(Level.FINE, "Jenkins is not running, no such node {0}, or it is offline", node); return null; } } boolean directory; try (Timeout timeout = Timeout.limit(10, TimeUnit.SECONDS)) { directory = ws.isDirectory(); } catch (Exception x) { // RequestAbortedException, ChannelClosedException, EOFException, wrappers thereof; InterruptedException if it just takes too long. LOGGER.log(Level.FINE, node + " is evidently offline now", x); ws = null; if (!printedCannotContactMessage) { logger().println("Cannot contact " + node + ": " + x); printedCannotContactMessage = true; } return null; } if (!directory) { throw new AbortException("missing workspace " + remote + " on " + node); } return ws; }