Package jenkins.scm

Class 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 in AbstractBuild.

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 to MatrixRuns by other means such as rsync.
  • MatrixBuild does no check out of its own, and check out is only done on MatrixRuns

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 the super.preCheckout so that matrix projects can satisfy the contract with BuildWrappers.

checkout

The default implementation uses AbstractProject.checkout(AbstractBuild, Launcher, BuildListener, File) to let SCM do check out, but your SCMCheckoutStrategy impls 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.