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()); }
@Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { MatrixProject mp = getParent().getParent(); // lock is done at the parent level, so that concurrent MatrixProjects get respective workspace, // but within MatrixConfigurations that belong to the same MatrixBuild. // if MatrixProject is configured with custom workspace, we assume that the user knows what he's doing // and try not to append unique random suffix. Lease baseLease = getParentWorkspaceLease(n,wsl); // resolve the relative path against the parent workspace, which needs locking FilePath baseDir = baseLease.path; // prepare variables that can be used in the child workspace setting EnvVars env = getEnvironment(listener); env.put("COMBINATION",getParent().getCombination().toString('/','/')); // e.g., "axis1/a/axis2/b" env.put("SHORT_COMBINATION",getParent().getDigestName()); // e.g., "0fbcab35" env.put("PARENT_WORKSPACE",baseDir.getRemote()); env.putAll(getBuildVariables()); // child workspace need no individual locks, whether or not we use custom workspace String childWs = mp.getChildCustomWorkspace(); return Lease.createLinkedDummyLease(baseDir.child(env.expand(childWs)),baseLease); } }
@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)); } } }