hudson.fsp
Class WorkspaceSnapshotSCM

java.lang.Object
  extended by hudson.scm.SCM
      extended by hudson.fsp.WorkspaceSnapshotSCM
All Implemented Interfaces:
ExtensionPoint, Describable<SCM>

public class WorkspaceSnapshotSCM
extends SCM

SCM that inherits the workspace from another build through WorkspaceSnapshot

Author:
Kohsuke Kawaguchi

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 String jobName
          The job name from which we inherit the workspace.
 String permalink
          The permalink name indicating the build from which to inherit the workspace.
 
Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
 
Constructor Summary
WorkspaceSnapshotSCM(String jobName, String permalink)
           
 
Method Summary
 SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?,?> build, Launcher launcher, TaskListener listener)
          Calculates the SCMRevisionState that represents the state of the workspace of the given build.
 boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changelogFile)
          Obtains a fresh workspace of the module(s) into the specified directory of the specified machine.
protected  PollingResult compareRemoteRevisionWith(AbstractProject project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline)
          Compares the current state of the remote repository against the given baseline SCMRevisionState.
 ChangeLogParser createChangeLogParser()
          The returned object will be used to parse changelog.xml.
 SCMDescriptor<?> getDescriptor()
          Gets the descriptor for this instance.
 hudson.fsp.WorkspaceSnapshotSCM.Snapshot resolve()
          Obtains the WorkspaceSnapshot object that this SCM points to, or throws ResolvedFailedException upon failing.
 
Methods inherited from class hudson.scm.SCM
_calcRevisionsFromBuild, _for, all, buildEnvVars, createEmptyChangeLog, getApi, getBrowser, getEffectiveBrowser, getModuleRoot, getModuleRoot, getModuleRoots, getModuleRoots, getType, nullify, poll, pollChanges, processWorkspaceBeforeDeletion, requiresWorkspaceForPolling, supportsPolling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobName

public String jobName
The job name from which we inherit the workspace.


permalink

public String permalink
The permalink name indicating the build from which to inherit the workspace.

Constructor Detail

WorkspaceSnapshotSCM

@DataBoundConstructor
public WorkspaceSnapshotSCM(String jobName,
                                                 String permalink)
Method Detail

resolve

public hudson.fsp.WorkspaceSnapshotSCM.Snapshot resolve()
                                                 throws hudson.fsp.WorkspaceSnapshotSCM.ResolvedFailedException
Obtains the WorkspaceSnapshot object that this SCM points to, or throws ResolvedFailedException upon failing.

Returns:
never null.
Throws:
hudson.fsp.WorkspaceSnapshotSCM.ResolvedFailedException

calcRevisionsFromBuild

public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?,?> build,
                                               Launcher launcher,
                                               TaskListener listener)
                                        throws IOException,
                                               InterruptedException
Description copied from class: SCM
Calculates the SCMRevisionState that represents the state of the workspace of the given build.

The returned object is then fed into the SCM.compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState) method as the baseline SCMRevisionState to determine if the build is necessary.

This method is called after source code is checked out for the given build (that is, after SCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File) has finished successfully.)

The obtained object is added to the build as an Action for later retrieval. As an optimization, SCM implementation can choose to compute SCMRevisionState and add it as an action during check out, in which case this method will not called.

Specified by:
calcRevisionsFromBuild in class SCM
Parameters:
build - The calculated SCMRevisionState is for the files checked out in this build. Never null. If SCM.requiresWorkspaceForPolling() returns true, Hudson makes sure that the workspace of this build is available and accessible by the callee.
launcher - Abstraction of the machine where the polling will take place. If SCM declares that the polling doesn't require a workspace, this parameter is null. Otherwise never null.
listener - Logs during the polling should be sent here.
Returns:
can be null.
Throws:
InterruptedException - interruption is usually caused by the user aborting the computation. this exception should be simply propagated all the way up.
IOException

compareRemoteRevisionWith

protected PollingResult compareRemoteRevisionWith(AbstractProject project,
                                                  Launcher launcher,
                                                  FilePath workspace,
                                                  TaskListener listener,
                                                  SCMRevisionState baseline)
                                           throws IOException,
                                                  InterruptedException
Description copied from class: SCM
Compares the current state of the remote repository against the given baseline SCMRevisionState.

Conceptually, the act of polling is to take two states of the repository and to compare them to see if there's any difference. In practice, however, comparing two arbitrary repository states is an expensive operation, so in this abstraction, we chose to mix (1) the act of building up a repository state and (2) the act of comparing it with the earlier state, so that SCM implementations can implement this more easily.

Multiple invocations of this method may happen over time to make sure that the remote repository is "quiet" before Hudson schedules a new build.

Specified by:
compareRemoteRevisionWith in class SCM
Parameters:
project - The project to check for updates
launcher - Abstraction of the machine where the polling will take place. If SCM declares that the polling doesn't require a workspace, this parameter is null.
workspace - The workspace directory that contains baseline files. If SCM declares that the polling doesn't require a workspace, this parameter is null.
listener - Logs during the polling should be sent here.
baseline - The baseline of the comparison. This object is the return value from earlier SCM.compareRemoteRevisionWith(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState) or SCM.calcRevisionsFromBuild(AbstractBuild, Launcher, TaskListener).
Returns:
This method returns multiple values that are bundled together into the PollingResult value type. PollingResult.baseline should be the value of the baseline parameter, PollingResult.remote is the current state of the remote repository (this object only needs to be understandable to the future invocations of this method), and PollingResult.change that indicates the degree of changes found during the comparison.
Throws:
InterruptedException - interruption is usually caused by the user aborting the computation. this exception should be simply propagated all the way up.
IOException

checkout

public boolean checkout(AbstractBuild build,
                        Launcher launcher,
                        FilePath workspace,
                        BuildListener listener,
                        File changelogFile)
                 throws IOException,
                        InterruptedException
Description copied from class: SCM
Obtains a fresh workspace of the module(s) into the specified directory of the specified machine.

The "update" operation can be performed instead of a fresh checkout if feasible.

This operation should also capture the information necessary to tag the workspace later.

Specified by:
checkout in class SCM
launcher - Abstracts away the machine that the files will be checked out.
workspace - a directory to check out the source code. May contain left-over from the previous build.
changelogFile - Upon a successful return, this file should capture the changelog. When there's no change, this file should contain an empty entry. See SCM.createEmptyChangeLog(File, BuildListener, String).
Returns:
false if the operation fails. The error should be reported to the listener. Otherwise return the changes included in this update (if this was an update.)

Using the return value to indicate success/failure should be considered deprecated, and implementations are encouraged to throw AbortException to indicate a failure.

Throws:
InterruptedException - interruption is usually caused by the user aborting the build. this exception will cause the build to be aborted.
IOException

createChangeLogParser

public ChangeLogParser createChangeLogParser()
Description copied from class: SCM
The returned object will be used to parse changelog.xml.

Specified by:
createChangeLogParser in class SCM

getDescriptor

public SCMDescriptor<?> getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<SCM>
Overrides:
getDescriptor in class SCM


Copyright © 2004-2013. All Rights Reserved.