Package org.jenkinsci.plugins.p4
Class PerforceScm
- java.lang.Object
-
- hudson.scm.SCM
-
- org.jenkinsci.plugins.p4.PerforceScm
-
- All Implemented Interfaces:
ExtensionPoint,Describable<SCM>
public class PerforceScm extends SCM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPerforceScm.DescriptorImplThe relationship of Descriptor and SCM (the describable) is akin to class and object.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CHANGE_LIMITstatic intDEFAULT_FILE_LIMITstatic longDEFAULT_HEAD_LIMIT-
Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
-
-
Constructor Summary
Constructors Constructor Description PerforceScm(String credential, Workspace workspace, List<Filter> filter, Populate populate, P4Browser browser)Create a constructor that takes non-transient fields, and add the annotation @DataBoundConstructor to it.PerforceScm(String credential, Workspace workspace, Populate populate)Internal constructor for functional tests.PerforceScm(AbstractP4ScmSource source, P4Path path, P4Ref revision)MultiBranch constructor for building jobs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildEnvironment(Run<?,?> run, Map<String,String> env)SCMRevisionStatecalcRevisionsFromBuild(Run<?,?> run, FilePath buildWorkspace, Launcher launcher, TaskListener listener)Calculate the state of the workspace of the given build.voidcheckout(Run<?,?> run, Launcher launcher, FilePath buildWorkspace, TaskListener listener, File changelogFile, SCMRevisionState baseline)The checkout method is expected to check out modified files into the project workspace.PollingResultcompareRemoteRevisionWith(Job<?,?> job, Launcher launcher, FilePath buildWorkspace, TaskListener listener, SCMRevisionState baseline)This method does the actual polling and returns a PollingResult.static PerforceScmconvertToPerforceScm(SCM scm)Helper function for converting an SCM object into a PerforceScm object when appropriate.ChangeLogParsercreateChangeLogParser()The checkout method should, besides checking out the modified files, write a changelog.xml file that contains the changes for a certain build.static P4BrowserfindBrowser(String scmCredential)P4BrowsergetBrowser()StringgetCredential()PerforceScm.DescriptorImplgetDescriptor()List<Filter>getFilter()StringgetKey()PopulategetPopulate()P4ReviewgetReview()StringgetScriptPath(Item item)WorkspacegetWorkspace()booleanprocessWorkspaceBeforeDeletion(Job<?,?> job, FilePath buildWorkspace, Node node)Called before a workspace is deleted on the given node, to provide SCM an opportunity to perform clean up.booleanrequiresWorkspaceForPolling()This method should return true if the SCM requires a workspace for polling.voidsetReview(P4Review review)booleansupportsPolling()This methods determines if the SCM plugin can be used for polling-
Methods inherited from class hudson.scm.SCM
_calcRevisionsFromBuild, _for, _for, all, buildEnvVars, calcRevisionsFromBuild, checkout, compareRemoteRevisionWith, createEmptyChangeLog, createEmptyChangeLog, getApi, getEffectiveBrowser, getModuleRoot, getModuleRoot, getModuleRoots, getModuleRoots, getType, guessBrowser, nullify, poll, pollChanges, postCheckout, postCheckout, processWorkspaceBeforeDeletion
-
-
-
-
Field Detail
-
DEFAULT_FILE_LIMIT
public static final int DEFAULT_FILE_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_CHANGE_LIMIT
public static final int DEFAULT_CHANGE_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_HEAD_LIMIT
public static final long DEFAULT_HEAD_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PerforceScm
@DataBoundConstructor public PerforceScm(String credential, Workspace workspace, List<Filter> filter, Populate populate, P4Browser browser)
Create a constructor that takes non-transient fields, and add the annotation @DataBoundConstructor to it. Using the annotation helps the Stapler class to find which constructor that should be used when automatically copying values from a web form to a class.- Parameters:
credential- Credential IDworkspace- Workspace connection detailsfilter- Polling filterspopulate- Populate optionsbrowser- Browser options
-
PerforceScm
public PerforceScm(AbstractP4ScmSource source, P4Path path, P4Ref revision)
MultiBranch constructor for building jobs.- Parameters:
source- ScmSourcepath- Perforce project path and mappingsrevision- Perforce revision
-
-
Method Detail
-
getCredential
public String getCredential()
-
getWorkspace
public Workspace getWorkspace()
-
getPopulate
public Populate getPopulate()
-
getBrowser
public P4Browser getBrowser()
- Overrides:
getBrowserin classSCM
-
getReview
public P4Review getReview()
-
setReview
public void setReview(P4Review review)
-
convertToPerforceScm
public static PerforceScm convertToPerforceScm(SCM scm)
Helper function for converting an SCM object into a PerforceScm object when appropriate.- Parameters:
scm- the SCM object- Returns:
- a PerforceScm instance or null
-
calcRevisionsFromBuild
public SCMRevisionState calcRevisionsFromBuild(Run<?,?> run, FilePath buildWorkspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException
Calculate the state of the workspace of the given build. The returned object is then fed into compareRemoteRevisionWith as the baseline SCMRevisionState to determine if the build is necessary, and is added to the build as an Action for later retrieval.- Overrides:
calcRevisionsFromBuildin classSCM- Throws:
IOExceptionInterruptedException
-
compareRemoteRevisionWith
public PollingResult compareRemoteRevisionWith(Job<?,?> job, Launcher launcher, FilePath buildWorkspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException
This method does the actual polling and returns a PollingResult. The change attribute of the PollingResult the significance of the changes detected by this poll.- Overrides:
compareRemoteRevisionWithin classSCM- Throws:
IOExceptionInterruptedException
-
checkout
public void checkout(Run<?,?> run, Launcher launcher, FilePath buildWorkspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException
The checkout method is expected to check out modified files into the project workspace. In Perforce terms a 'p4 sync' on the project's workspace. Authorisation- Overrides:
checkoutin classSCM- Throws:
IOExceptionInterruptedException
-
buildEnvironment
public void buildEnvironment(Run<?,?> run, Map<String,String> env)
- Overrides:
buildEnvironmentin classSCM
-
createChangeLogParser
public ChangeLogParser createChangeLogParser()
The checkout method should, besides checking out the modified files, write a changelog.xml file that contains the changes for a certain build. The changelog.xml file is specific for each SCM implementation, and the createChangeLogParser returns a parser that can parse the file and return a ChangeLogSet.- Specified by:
createChangeLogParserin classSCM
-
processWorkspaceBeforeDeletion
public boolean processWorkspaceBeforeDeletion(Job<?,?> job, FilePath buildWorkspace, Node node) throws IOException, InterruptedException
Called before a workspace is deleted on the given node, to provide SCM an opportunity to perform clean up.- Overrides:
processWorkspaceBeforeDeletionin classSCM- Throws:
IOExceptionInterruptedException
-
getDescriptor
public PerforceScm.DescriptorImpl getDescriptor()
- Specified by:
getDescriptorin interfaceDescribable<SCM>- Overrides:
getDescriptorin classSCM
-
supportsPolling
public boolean supportsPolling()
This methods determines if the SCM plugin can be used for polling- Overrides:
supportsPollingin classSCM
-
requiresWorkspaceForPolling
public boolean requiresWorkspaceForPolling()
This method should return true if the SCM requires a workspace for polling. Perforce however can report submitted, pending and shelved changes without needing a workspace- Overrides:
requiresWorkspaceForPollingin classSCM
-
-