hudson.plugins.perforce
Class PerforceSCM

java.lang.Object
  extended by hudson.scm.SCM
      extended by hudson.plugins.perforce.PerforceSCM
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.scm.SCM>

public class PerforceSCM
extends hudson.scm.SCM

Extends SCM to provide integration with Perforce SCM repositories.

Author:
Mike Wille, Brian Westrich, Victor Szoltysek

Nested Class Summary
static class PerforceSCM.PerforceSCMDescriptor
           
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
 
Constructor Summary
PerforceSCM(java.lang.String p4User, java.lang.String p4Passwd, java.lang.String p4Client, java.lang.String p4Port, java.lang.String projectPath, java.lang.String p4Exe, java.lang.String p4SysRoot, java.lang.String p4SysDrive, boolean forceSync, boolean updateView, int firstChange, PerforceRepositoryBrowser browser)
           
 
Method Summary
 void buildEnvVars(hudson.model.AbstractBuild build, java.util.Map<java.lang.String,java.lang.String> env)
          Override of SCM.buildEnvVars() in order to setup the last change we have sync'd to as a Hudson environment variable: P4_CHANGELIST
 boolean checkout(hudson.model.AbstractBuild build, hudson.Launcher launcher, hudson.FilePath workspace, hudson.model.BuildListener listener, java.io.File changelogFile)
           
 hudson.scm.ChangeLogParser createChangeLogParser()
           
 PerforceRepositoryBrowser getBrowser()
           
protected  com.tek42.perforce.Depot getDepot()
          Used for MailResolver
protected  com.tek42.perforce.Depot getDepot(hudson.Launcher launcher, hudson.FilePath workspace)
          This only exists because we need to do initialization after we have been brought back to life.
 java.lang.String getFirstChange()
          This is only for the config screen.
 int getLastChange(hudson.model.Run build)
           
 java.lang.String getP4Client()
           
 java.lang.String getP4Exe()
           
 java.lang.String getP4Passwd()
           
 java.lang.String getP4Port()
           
 java.lang.String getP4SysDrive()
           
 java.lang.String getP4SysRoot()
           
 java.lang.String getP4User()
           
 java.lang.String getProjectPath()
           
 boolean isForceSync()
           
 boolean isUpdateView()
           
 boolean pollChanges(hudson.model.AbstractProject project, hudson.Launcher launcher, hudson.FilePath workspace, hudson.model.TaskListener listener)
           
 boolean processWorkspaceBeforeDeletion(hudson.model.AbstractProject<?,?> project, hudson.FilePath workspace, hudson.model.Node node)
          With Perforce the server keeps track of files in the workspace.
 void setForceSync(boolean force)
           
 void setP4Client(java.lang.String client)
           
 void setP4Exe(java.lang.String exe)
           
 void setP4Passwd(java.lang.String passwd)
           
 void setP4Port(java.lang.String port)
           
 void setP4SysDrive(java.lang.String sysDrive)
           
 void setP4SysRoot(java.lang.String sysRoot)
           
 void setP4User(java.lang.String user)
           
 void setProjectPath(java.lang.String projectPath)
           
 void setUpdateView(boolean update)
           
 
Methods inherited from class hudson.scm.SCM
_for, all, createEmptyChangeLog, getDescriptor, getEffectiveBrowser, getModuleRoot, getModuleRoots, nullify, requiresWorkspaceForPolling, supportsPolling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerforceSCM

@DataBoundConstructor
public PerforceSCM(java.lang.String p4User,
                                        java.lang.String p4Passwd,
                                        java.lang.String p4Client,
                                        java.lang.String p4Port,
                                        java.lang.String projectPath,
                                        java.lang.String p4Exe,
                                        java.lang.String p4SysRoot,
                                        java.lang.String p4SysDrive,
                                        boolean forceSync,
                                        boolean updateView,
                                        int firstChange,
                                        PerforceRepositoryBrowser browser)
Method Detail

getDepot

protected com.tek42.perforce.Depot getDepot(hudson.Launcher launcher,
                                            hudson.FilePath workspace)
This only exists because we need to do initialization after we have been brought back to life. I'm not quite clear on stapler and how all that works. At any rate, it doesn't look like we have an init() method for setting up our Depot after all of the setters have been called. Someone correct me if I'm wrong... UPDATE: With the addition of PerforceMailResolver, we now have need to share the depot object. I'm making this protected to enable that. Always create a new Depot to reflect any changes to the machines that P4 actions will be performed on.


getDepot

protected com.tek42.perforce.Depot getDepot()
Used for MailResolver


buildEnvVars

public void buildEnvVars(hudson.model.AbstractBuild build,
                         java.util.Map<java.lang.String,java.lang.String> env)
Override of SCM.buildEnvVars() in order to setup the last change we have sync'd to as a Hudson environment variable: P4_CHANGELIST

Overrides:
buildEnvVars in class hudson.scm.SCM
Parameters:
build -
env -

checkout

public boolean checkout(hudson.model.AbstractBuild build,
                        hudson.Launcher launcher,
                        hudson.FilePath workspace,
                        hudson.model.BuildListener listener,
                        java.io.File changelogFile)
                 throws java.io.IOException,
                        java.lang.InterruptedException
Specified by:
checkout in class hudson.scm.SCM
Throws:
java.io.IOException
java.lang.InterruptedException

getBrowser

public PerforceRepositoryBrowser getBrowser()
Overrides:
getBrowser in class hudson.scm.SCM

createChangeLogParser

public hudson.scm.ChangeLogParser createChangeLogParser()
Specified by:
createChangeLogParser in class hudson.scm.SCM

pollChanges

public boolean pollChanges(hudson.model.AbstractProject project,
                           hudson.Launcher launcher,
                           hudson.FilePath workspace,
                           hudson.model.TaskListener listener)
                    throws java.io.IOException,
                           java.lang.InterruptedException
Specified by:
pollChanges in class hudson.scm.SCM
Throws:
java.io.IOException
java.lang.InterruptedException

getLastChange

public int getLastChange(hudson.model.Run build)

getProjectPath

public java.lang.String getProjectPath()
Returns:
the projectPath

setProjectPath

public void setProjectPath(java.lang.String projectPath)
Parameters:
projectPath - the projectPath to set

getP4User

public java.lang.String getP4User()
Returns:
the p4User

setP4User

public void setP4User(java.lang.String user)
Parameters:
user - the p4User to set

getP4Passwd

public java.lang.String getP4Passwd()
Returns:
the p4Passwd

setP4Passwd

public void setP4Passwd(java.lang.String passwd)
Parameters:
passwd - the p4Passwd to set

getP4Port

public java.lang.String getP4Port()
Returns:
the p4Port

setP4Port

public void setP4Port(java.lang.String port)
Parameters:
port - the p4Port to set

getP4Client

public java.lang.String getP4Client()
Returns:
the p4Client

setP4Client

public void setP4Client(java.lang.String client)
Parameters:
client - the p4Client to set

getP4SysDrive

public java.lang.String getP4SysDrive()
Returns:
the p4SysDrive

setP4SysDrive

public void setP4SysDrive(java.lang.String sysDrive)
Parameters:
sysDrive - the p4SysDrive to set

getP4SysRoot

public java.lang.String getP4SysRoot()
Returns:
the p4SysRoot

setP4SysRoot

public void setP4SysRoot(java.lang.String sysRoot)
Parameters:
sysRoot - the p4SysRoot to set

getP4Exe

public java.lang.String getP4Exe()
Returns:
the p4Exe

setP4Exe

public void setP4Exe(java.lang.String exe)
Parameters:
exe - the p4Exe to set

setUpdateView

public void setUpdateView(boolean update)
Parameters:
update - True to let the plugin manage the view, false to let the user manage it

isUpdateView

public boolean isUpdateView()
Returns:
True if the plugin manages the view, false if the user does.

isForceSync

public boolean isForceSync()
Returns:
True if we are performing a one-time force sync

setForceSync

public void setForceSync(boolean force)
Parameters:
force - True to perform a one time force sync, false to perform normal sync

getFirstChange

public java.lang.String getFirstChange()
This is only for the config screen. Also, it returns a string and not an int. This is because we want to show an empty value in the config option if it is not being used. The default value of -1 is not exactly empty. So if we are set to default of -1, we return an empty string. Anything else and we return the actual change number.

Returns:
The one time use variable, firstChange.

processWorkspaceBeforeDeletion

public boolean processWorkspaceBeforeDeletion(hudson.model.AbstractProject<?,?> project,
                                              hudson.FilePath workspace,
                                              hudson.model.Node node)
With Perforce the server keeps track of files in the workspace. We never want files deleted without the knowledge of the server so we disable the cleanup process.

Overrides:
processWorkspaceBeforeDeletion in class hudson.scm.SCM
Parameters:
project - The project that owns this SCM. This is always the same object for a particular instanceof SCM. Just passed in here so that SCM itself doesn't have to remember the value.
workspace - The workspace which is about to be deleted. Never null. This can be a remote file path.
node - The node that hosts the workspace. SCM can use this information to determine the course of action.
Returns:
true if SCM is OK to let Hudson proceed with deleting the workspace. False to veto the workspace deletion.


Copyright © 2009. All Rights Reserved.