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 class
PerforceScm.DescriptorImpl
The 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 int
DEFAULT_CHANGE_LIMIT
static int
DEFAULT_FILE_LIMIT
static long
DEFAULT_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 void
buildEnvironment(Run<?,?> run, Map<String,String> env)
SCMRevisionState
calcRevisionsFromBuild(Run<?,?> run, FilePath buildWorkspace, Launcher launcher, TaskListener listener)
Calculate the state of the workspace of the given build.void
checkout(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.PollingResult
compareRemoteRevisionWith(Job<?,?> job, Launcher launcher, FilePath buildWorkspace, TaskListener listener, SCMRevisionState baseline)
This method does the actual polling and returns a PollingResult.static PerforceScm
convertToPerforceScm(SCM scm)
Helper function for converting an SCM object into a PerforceScm object when appropriate.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.static P4Browser
findBrowser(String scmCredential)
P4Browser
getBrowser()
String
getCredential()
PerforceScm.DescriptorImpl
getDescriptor()
List<Filter>
getFilter()
String
getKey()
Populate
getPopulate()
P4Review
getReview()
String
getScriptPath(Item item)
Workspace
getWorkspace()
boolean
processWorkspaceBeforeDeletion(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.boolean
requiresWorkspaceForPolling()
This method should return true if the SCM requires a workspace for polling.void
setReview(P4Review review)
boolean
supportsPolling()
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:
getBrowser
in 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:
calcRevisionsFromBuild
in classSCM
- Throws:
IOException
InterruptedException
-
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:
compareRemoteRevisionWith
in classSCM
- Throws:
IOException
InterruptedException
-
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:
checkout
in classSCM
- Throws:
IOException
InterruptedException
-
buildEnvironment
public void buildEnvironment(Run<?,?> run, Map<String,String> env)
- Overrides:
buildEnvironment
in 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:
createChangeLogParser
in 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:
processWorkspaceBeforeDeletion
in classSCM
- Throws:
IOException
InterruptedException
-
getDescriptor
public PerforceScm.DescriptorImpl getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<SCM>
- Overrides:
getDescriptor
in classSCM
-
supportsPolling
public boolean supportsPolling()
This methods determines if the SCM plugin can be used for polling- Overrides:
supportsPolling
in 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:
requiresWorkspaceForPolling
in classSCM
-
-