/** * See {@link #allocate(FilePath)} * * @param context * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ public synchronized Lease allocate(@Nonnull FilePath base, Object context) throws InterruptedException { for (int i=1; ; i++) { FilePath candidate = i==1 ? base : base.withSuffix(COMBINATOR+i); Entry e = inUse.get(candidate); if(e!=null && !e.quick && e.context!=context) continue; return acquire(candidate,false,context); } }
/** * Allocates a workspace by adding some variation to the given base to make it unique. */ public synchronized Lease allocate(FilePath base) throws InterruptedException { for (int i=1; ; i++) { //Workspace suffix was changed from @ to _, because of some issues with SCMs. //see http://issues.hudson-ci.org/browse/HUDSON-4791 FilePath candidate = i==1 ? base : base.withSuffix(WORKSPACE_NAME_SUFFIX + i); Entry e = inUse.get(candidate); if(e!=null && !e.quick) continue; return acquire(candidate); } }
private FilePath getFilePathWithSuffix(FilePath baseWorkspace) { return baseWorkspace.withSuffix(getFilePathSuffix() + "script"); }
/** * Allocates a workspace by adding some variation to the given base to make it unique. */ public synchronized Lease allocate(FilePath base) throws InterruptedException { for (int i=1; ; i++) { //Workspace suffix was changed from @ to _, because of some issues with SCMs. //see http://issues.hudson-ci.org/browse/HUDSON-4791 FilePath candidate = i==1 ? base : base.withSuffix(WORKSPACE_NAME_SUFFIX + i); Entry e = inUse.get(candidate); if(e!=null && !e.quick) continue; return acquire(candidate); } }
/** * Allocates a workspace by adding some variation to the given base to make it unique. */ public synchronized Lease allocate(FilePath base) throws InterruptedException { for (int i=1; ; i++) { //Workspace suffix was changed from @ to _, because of some issues with SCMs. //see http://issues.hudson-ci.org/browse/HUDSON-4791 FilePath candidate = i==1 ? base : base.withSuffix(WORKSPACE_NAME_SUFFIX + i); Entry e = inUse.get(candidate); if(e!=null && !e.quick) continue; return acquire(candidate); } }
/** * See {@link #allocate(FilePath)} * * @param context * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ public synchronized Lease allocate(@Nonnull FilePath base, Object context) throws InterruptedException { for (int i=1; ; i++) { FilePath candidate = i==1 ? base : base.withSuffix(COMBINATOR+i); Entry e = inUse.get(candidate); if(e!=null && !e.quick && e.context!=context) continue; return acquire(candidate,false,context); } }
private FilePath getFilePathWithSuffix(FilePath baseWorkspace) { return baseWorkspace.withSuffix(getFilePathSuffix() + "script"); }
private FilePath getFilePathWithSuffix(FilePath baseWorkspace) { return baseWorkspace.withSuffix(getFilePathSuffix() + "script"); }
/** * Allocates a workspace by adding some variation to the given base to make * it unique. */ public synchronized Lease allocate(FilePath base) throws InterruptedException { for (int i = 1;; i++) { //Workspace suffix was changed from @ to _, because of some issues with SCMs. //see http://issues.hudson-ci.org/browse/HUDSON-4791 FilePath candidate = i == 1 ? base : base.withSuffix(WORKSPACE_NAME_SUFFIX + i); Entry e = inUse.get(candidate); if (e != null && !e.quick) { continue; } return acquire(candidate); } }
private FilePath getSourceDirectory(FilePath basePath) throws IOException, InterruptedException { String subdirectory = StringUtils.trimToEmpty(getSubdirectoryFromEnv()); if (!subdirectory.isEmpty() && !subdirectory.startsWith("/")) { subdirectory = "/" + subdirectory; } FilePath sourcePath = basePath.withSuffix(subdirectory).absolutize(); if (!sourcePath.isDirectory() || !isSubDirectory(basePath, sourcePath)) { throw new IllegalArgumentException("Provided path (resolved as '" + sourcePath +"') is not a subdirectory of the workspace (resolved as '" + basePath + "')"); } return sourcePath; }
build.getWorkspace().withSuffix("/" + configuredPath).copyTo(new FileOutputStream(tempJDependFile)); p = getJDependParser(tempJDependFile); if (!tempJDependFile.delete()) {
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); } }
AbstractProject project = (AbstractProject) item; for (int i=1; ; i++) { FilePath candidate = i == 1 ? child : child.withSuffix(COMBINATOR + i); boolean candidateInUse = false; for (Object run : project.getBuilds()) {