Class SCMCheckoutStrategy
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<SCMCheckoutStrategy>
-
- jenkins.scm.SCMCheckoutStrategy
-
- All Implemented Interfaces:
ExtensionPoint,Describable<SCMCheckoutStrategy>
- Direct Known Subclasses:
DefaultSCMCheckoutStrategyImpl
public abstract class SCMCheckoutStrategy extends AbstractDescribableImpl<SCMCheckoutStrategy> implements ExtensionPoint
Controls the check out behavior inAbstractBuild.While this can work with any
AbstractBuild, the primary motivation of this extension point is to control the check out behaviour in matrix projects. The intended use cases include situations like:- Check out will only happen once in
MatrixBuild, and its state will be then sent toMatrixRuns by other means such as rsync. MatrixBuilddoes no check out of its own, and check out is only done onMatrixRuns
Hook Semantics
There are currently two hooks defined on this class:pre checkout
The default implementation calls into
BuildWrapper.preCheckout(AbstractBuild, Launcher, BuildListener)calls. You can override this method to do something before/after this, but you must still call into thesuper.preCheckoutso that matrix projects can satisfy the contract withBuildWrappers.checkout
The default implementation uses
AbstractProject.checkout(AbstractBuild, Launcher, BuildListener, File)to letSCMdo check out, but yourSCMCheckoutStrategyimpls can substitute this call with other operations that substitutes this semantics.State and concurrency
An instance of this object gets created for a project for which this strategy is configured, so the subtype needs to avoid using instance variables to refer to build-specific state (such as
BuildListeners.) Similarly, methods can be invoked concurrently. The code executes on the master, even if builds are running remotely.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description SCMCheckoutStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckout(AbstractBuild.AbstractBuildExecution execution)Performs the checkout step.SCMCheckoutStrategyDescriptorgetDescriptor()By default looks for a nested class (conventionally namedDescriptorImpl) implementingDescriptorand marked withExtension.voidpreCheckout(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)Performs the pre checkout step.
-
-
-
Method Detail
-
preCheckout
public void preCheckout(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
Performs the pre checkout step. This method is called by theExecutorthat's carrying out the build.- Parameters:
build- Build being in progress. Never null.launcher- Allows you to launch process on the node where the build is actually running. Never null.listener- Allows you to write to console output and report errors. Never null.- Throws:
IOExceptionInterruptedException
-
checkout
public void checkout(AbstractBuild.AbstractBuildExecution execution) throws IOException, InterruptedException
Performs the checkout step. SeepreCheckout(AbstractBuild, Launcher, BuildListener)for the semantics of the parameters.- Throws:
IOExceptionInterruptedException
-
getDescriptor
public SCMCheckoutStrategyDescriptor getDescriptor()
Description copied from class:AbstractDescribableImplBy default looks for a nested class (conventionally namedDescriptorImpl) implementingDescriptorand marked withExtension.Gets the descriptor for this instance.
Descriptoris a singleton for every concreteDescribableimplementation, so ifa.getClass() == b.getClass()then by defaulta.getDescriptor() == b.getDescriptor()as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptorin interfaceDescribable<SCMCheckoutStrategy>- Overrides:
getDescriptorin classAbstractDescribableImpl<SCMCheckoutStrategy>
-
-