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

1 package jenkins.scm;
2
3 import hudson.ExtensionPoint;
4 import hudson.Launcher;
5 import hudson.matrix.MatrixBuild;
6 import hudson.matrix.MatrixRun;
7 import hudson.model.AbstractBuild;
8 import hudson.model.AbstractBuild.AbstractBuildExecution;
9 import hudson.model.AbstractDescribableImpl;
10 import hudson.model.AbstractProject;
11 import hudson.model.BuildListener;
12 import hudson.model.BuildableItemWithBuildWrappers;
13 import hudson.model.Executor;
14 import hudson.scm.SCM;
15 import hudson.tasks.BuildWrapper;
16
17 import java.io.File;
18 import java.io.IOException;
19
20 /**
21 * Controls the check out behavior in the matrix project.
22 *
23 * <p>
24 * This extension point can be used to control the check out behaviour in matrix projects. The intended use cases
25 * include situations like:
26 *
27 * <ul>
28 * <li>Check out will only happen once in {@link MatrixBuild}, and its state will be then sent
29 * to {@link MatrixRun}s by other means such as rsync.
30 * <li>{@link MatrixBuild} does no check out of its own, and check out is only done on {@link MatrixRun}s
31 * </ul>
32 *
33 * <h2>Hook Semantics</h2>
34 * There are currently two hooks defined on this class:
35 *
36 * <h3>pre checkout</h3>
37 * <p>
38 * The default implementation calls into {@link BuildWrapper#preCheckout(AbstractBuild, Launcher, BuildListener)} calls.
39 * You can override this method to do something before/after this, but you must still call into the {@code super.preCheckout}
40 * so that matrix projects can satisfy the contract with {@link BuildWrapper}s.
41 *
42 * <h3>checkout</h3>
43 * <p>
44 * The default implementation uses {@link AbstractProject#checkout(AbstractBuild, Launcher, BuildListener, File)} to
45 * let {@link SCM} do check out, but your {@link SCMCheckoutStrategy} impls can substitute this call with other
46 * operations that substitutes this semantics.
47 *
48 * <h2>State and concurrency</h2>
49 * <p>
50 * An instance of this object gets created for a project for which this strategy is configured, so
51 * the subtype needs to avoid using instance variables to refer to build-specific state (such as {@link BuildListener}s.)
52 * Similarly, methods can be invoked concurrently. The code executes on the master, even if builds are running remotely.
53 */
54 public abstract class SCMCheckoutStrategy extends AbstractDescribableImpl<SCMCheckoutStrategy> implements ExtensionPoint {
55
56 /*
57 Default behavior is defined in AbstractBuild.AbstractRunner, which is the common
58 implementation for not just matrix projects but all sorts of other project types.
59 */
60
61 /**
62 * Performs the pre checkout step.
63 *
64 * This method is called by the {@link Executor} that's carrying out the build.
65 *
66 * @param build
67 * Build being in progress. Never null.
68 * @param launcher
69 * Allows you to launch process on the node where the build is actually running. Never null.
70 * @param listener
71 * Allows you to write to console output and report errors. Never null.
72 */
73 public void preCheckout(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
74 AbstractProject<?, ?> project = build.getProject();
75 if (project instanceof BuildableItemWithBuildWrappers) {
76 BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) project;
77 for (BuildWrapper bw : biwbw.getBuildWrappersList())
78 bw.preCheckout(build,launcher,listener);
79 }
80 }
81
82 /**
83 * Performs the checkout step.
84 *
85 * See {@link #preCheckout(AbstractBuild, Launcher, BuildListener)} for the semantics of the parameters.
86 */
87 public void checkout(AbstractBuildExecution execution) throws IOException, InterruptedException {
88 execution.defaultCheckout();
89 }
90
91 @Override
92 public SCMCheckoutStrategyDescriptor getDescriptor() {
93 return (SCMCheckoutStrategyDescriptor)super.getDescriptor();
94 }
95
96 }
97