FilePath ws = node.getWorkspaceFor(item); if (ws == null) { continue; // offline, fine
private boolean isContainedInWorkspace(TopLevelItem item, Node node, String path){ if(node instanceof Slave){ Slave slave = (Slave) node; return path.contains(slave.getRemoteFS()); } else{ if(node instanceof Jenkins){ FilePath file = Jenkins.getInstance().getWorkspaceFor(item); return path.contains(file.getRemote()); } else{ try{ return path.contains(node.getWorkspaceFor(item).getRemote()); } catch(Exception e){ return false; } } } }
public static FilePath getWorkspacePathFor( Node n, InheritanceProject project, Map<String, String> values) { String path = project.getParameterizedWorkspace(); if (path == null || path.isEmpty()) { return null; } //Resolve the path's variables String resolv = Resolver.resolveSingle(values, path); if (resolv == null) { return null; } resolv = resolv.trim(); if (resolv.isEmpty()) { return null; } //Check if the path looks absolute; if not put it under the node if (PathMapping.isAbsolute(resolv) == false) { FilePath root = n.getWorkspaceFor(project); if (root != null) { root = root.getParent(); resolv = PathMapping.join(root.getRemote(), resolv); } } return new FilePath(n.getChannel(), resolv); }
protected Lease getParentWorkspaceLease(Node n, WorkspaceList wsl) throws InterruptedException, IOException { MatrixProject mp = getParent().getParent(); String customWorkspace = mp.getCustomWorkspace(); if (customWorkspace != null) { final FilePath nodeRoot = n.getRootPath(); if (nodeRoot == null) { throw new IOException("Cannot retrieve the node's root. Most probably it's offline"); } // we allow custom workspaces to be concurrently used between jobs. return Lease.createDummyLease(nodeRoot.child(getEnvironment(listener).expand(customWorkspace))); } final FilePath workspace = n.getWorkspaceFor(mp); if (workspace == null) { throw new IOException("Cannot retrieve the node's workspace for " + mp + ". Most probably the node is offline"); } return wsl.allocate(workspace, getParentBuild()); }
FilePath root = n.getWorkspaceFor(project); if (root != null) { root = root.getParent(); return n.getWorkspaceFor(project);
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { if (getTarget() == null) { throw new IOException("No Promotion target, cannot retrieve workspace"); } String customWorkspace = Promotion.this.getProject().getCustomWorkspace(); if (customWorkspace != null) { final FilePath rootPath = n.getRootPath(); if (rootPath == null) { throw new IOException("Cannot retrieve the root path of the node " + n); } // we allow custom workspaces to be concurrently used between jobs. return Lease.createDummyLease( rootPath.child(getEnvironment(listener).expand(customWorkspace))); } TopLevelItem item = (TopLevelItem)getTarget().getProject(); FilePath workspace = n.getWorkspaceFor(item); if (workspace == null) { throw new IOException("Cannot retrieve workspace for " + item + " on the node " + n); } return wsl.allocate(workspace, promotionRun); }
FilePath path =null; try{ path = node.getWorkspaceFor((TopLevelItem)owner); if(path!=null && path.exists() && (diskUsage.slaveWorkspacesUsage.get(node.getNodeName())==null || !diskUsage.slaveWorkspacesUsage.get(node.getNodeName()).containsKey(path.getRemote()))){ putSlaveWorkspace(node, path.getRemote());
public Object readResolve() { //for keeping backward compatibility if(diskUsage!=null){ buildDiskUsage = diskUsage.buildUsage; Node node = build.getBuiltOn(); if(node!=null && diskUsage.wsUsage!=null && diskUsage.wsUsage > 0){ DiskUsageProperty property = (DiskUsageProperty) build.getProject().getProperty(DiskUsageProperty.class); AbstractProject project = build.getProject().getRootProject(); if(property!=null && (project instanceof TopLevelItem)) property.putSlaveWorkspaceSize(node, node.getWorkspaceFor((TopLevelItem)project).getRemote(), diskUsage.wsUsage); } diskUsage=null; } return this; }
FilePath ws = node.getWorkspaceFor(item); if (ws == null) { continue; // offline, fine
throw new Exception(j + " must be a top-level job"); FilePath p = node.getWorkspaceFor((TopLevelItem) j); if (p == null) { throw new IllegalStateException(node + " is offline");
protected Lease getParentWorkspaceLease(final Node n, final WorkspaceList wsl) throws InterruptedException, IOException { final DynamicProject mp = getParent().getParent(); final String customWorkspace = mp.getCustomWorkspace(); if (customWorkspace != null) { // we allow custom workspaces to be concurrently used between // jobs. return Lease.createDummyLease(n.getRootPath().child(getEnvironment(this.listener).expand(customWorkspace))); } return wsl.allocate(n.getWorkspaceFor(mp), getParentBuild()); }
throw new Exception(j + " must be a top-level job"); FilePath p = node.getWorkspaceFor((TopLevelItem) j); if (p == null) { throw new IllegalStateException(node + " is offline");
throw new Exception(j + " must be a top-level job"); FilePath p = node.getWorkspaceFor((TopLevelItem) j); if (p == null) { throw new IllegalStateException(node + " is offline");
static void doRetrieve(String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception { // Adapted from CpsScmFlowDefinition: SCMStep delegate = new GenericSCMStep(scm); delegate.setPoll(false); // TODO we have no API for determining if a given SCMHead is branch-like or tag-like; would we want to turn on polling if the former? delegate.setChangelog(changelog); FilePath dir; Node node = Jenkins.getActiveInstance(); if (run.getParent() instanceof TopLevelItem) { FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) run.getParent()); if (baseWorkspace == null) { throw new IOException(node.getDisplayName() + " may be offline"); } dir = baseWorkspace.withSuffix(getFilePathSuffix() + "libs").child(name); } else { // should not happen, but just in case: throw new AbortException("Cannot check out in non-top-level build"); } Computer computer = node.toComputer(); if (computer == null) { throw new IOException(node.getDisplayName() + " may be offline"); } try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) { delegate.checkout(run, lease.path, listener, node.createLauncher(listener)); // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care? // Copy sources with relevant files from the checkout: lease.path.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target); } }
FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) job); if (baseWorkspace == null) { throw new IllegalStateException(node + " is offline");
Node node = Jenkins.get(); if (build.getParent() instanceof TopLevelItem) { FilePath baseWorkspace = node.getWorkspaceFor((TopLevelItem) build.getParent()); if (baseWorkspace == null) { throw new IOException(node.getDisplayName() + " may be offline");
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { // Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'. String subtree; if(useShortWorkspaceName) { subtree = getParent().getDigestName(); } else { subtree = getParent().getCombination().toString('/','/', true); } String customWorkspace = getParent().getParent().getCustomWorkspace(); if (customWorkspace != null) { // Use custom workspace as defined in the matrix project settings. FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)); // We allow custom workspaces to be used concurrently between jobs. return Lease.createDummyLease(ws.child(subtree)); } else { // Use default workspace as assigned by Hudson. Node node = getBuiltOn(); FilePath ws = node.getWorkspaceFor(getParent().getParent()); // Allocate unique workspace (not to be shared between jobs and runs). return wsl.allocate(ws.child(subtree)); } } }
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { // Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'. String subtree; if (useShortWorkspaceName) { subtree = getParent().getDigestName(); } else { subtree = getParent().getCombination().toString('/', '/', true); } String customWorkspace = getParent().getParent().getCustomWorkspace(); if (customWorkspace != null) { // Use custom workspace as defined in the matrix project settings. FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)); // We allow custom workspaces to be used concurrently between jobs. return Lease.createDummyLease(ws.child(subtree)); } else { // Use default workspace as assigned by Hudson. Node node = getBuiltOn(); FilePath ws = node.getWorkspaceFor(getParent().getParent()); // Allocate unique workspace (not to be shared between jobs and runs). return wsl.allocate(ws.child(subtree)); } } }
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { // Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'. String subtree; if(useShortWorkspaceName) { subtree = getParent().getDigestName(); } else { subtree = getParent().getCombination().toString('/','/', true); } String customWorkspace = getParent().getParent().getCustomWorkspace(); if (customWorkspace != null) { // Use custom workspace as defined in the matrix project settings. FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)); // We allow custom workspaces to be used concurrently between jobs. return Lease.createDummyLease(ws.child(subtree)); } else { // Use default workspace as assigned by Hudson. Node node = getBuiltOn(); FilePath ws = node.getWorkspaceFor(getParent().getParent()); // Allocate unique workspace (not to be shared between jobs and runs). return wsl.allocate(ws.child(subtree)); } } }
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { // Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'. String subtree; if(useShortWorkspaceName) { subtree = getParent().getDigestName(); } else { subtree = getParent().getCombination().toString('/','/', true); } String customWorkspace = getParent().getParent().getCustomWorkspace(); if (customWorkspace != null) { // Use custom workspace as defined in the matrix project settings. FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)); // We allow custom workspaces to be used concurrently between jobs. return Lease.createDummyLease(ws.child(subtree)); } else { // Use default workspace as assigned by Hudson. Node node = getBuiltOn(); FilePath ws = node.getWorkspaceFor(getParent().getParent()); // Allocate unique workspace (not to be shared between jobs and runs). return wsl.allocate(ws.child(subtree)); } } }