File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\FileSystemProvisionerDescriptor.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson;
25
26 import hudson.model.Descriptor;
27 import hudson.model.TaskListener;
28
29 import java.io.IOException;
30
31 /**
32 * {@link Descriptor} for {@link FileSystemProvisioner}.
33 *
34 * @author Kohsuke Kawaguchi
35 */
36 public abstract class FileSystemProvisionerDescriptor extends Descriptor<FileSystemProvisioner> implements ExtensionPoint {
37 /**
38 * Called to clean up a workspace that may potentially belong to this {@link FileSystemProvisioner}.
39 *
40 * <p>
41 * Because users may modify the file system behind Hudson, and slaves may come and go when
42 * configuration changes hapen, in general case Hudson is unable to keep track of which jobs
43 * have workspaces in which slaves.
44 *
45 * <p>
46 * So instead we rey on a garbage collection mechanism, to look at workspaces left in the file system
47 * without the contextual information of the owner project, and try to clean that up.
48 *
49 * <p>
50 * This method is called to do this, after Hudson determines that the workspace should be deleted
51 * to reclaim disk space. The implementation of this method is expected to sniff the contents of
52 * the workspace, and if it looks like the one created by {@link FileSystemProvisioner#prepareWorkspace(AbstractBuild, FilePath, TaskListener)},
53 * perform the necessary deletion operation, and return <tt>true</tt>.
54 *
55 * <p>
56 * If the workspace isn't the one created by this {@link FileSystemProvisioner}, or if the
57 * workspace can be simply deleted by {@link FilePath#deleteRecursive()}, then simply
58 * return <tt>false</tt> to give other {@link FileSystemProvisionerDescriptor}s a chance to
59 * discard them.
60 *
61 * @param ws
62 * The workspace directory to be removed.
63 * @param listener
64 * The status of the operation, error message, etc., should go here.
65 * @return
66 * true if this {@link FileSystemProvisionerDescriptor} is responsible for de-alocating the workspace.
67 * false otherwise, in which case the other {@link FileSystemProvisionerDescriptor}s are asked to
68 * clean up the workspace.
69 */
70 public abstract boolean discard(FilePath ws, TaskListener listener) throws IOException, InterruptedException;
71 }
72