com.atlassian.bamboo.repository.perforce
Class PerforceRepository

java.lang.Object
  extended by com.atlassian.bamboo.repository.AbstractRepository
      extended by com.atlassian.bamboo.repository.perforce.PerforceRepository
All Implemented Interfaces:
ConvertibleFromConfig, CleanCheckoutAwareRepository, IncludeExcludeAwareRepository, MutableQuietPeriodAwareRepository, QuietPeriodAwareRepository, Repository, WebRepositoryEnabledRepository, BambooPluginModule, ConfigurablePlugin, PostConfigurableRepository, RepositoryV2, java.io.Serializable

public class PerforceRepository
extends AbstractRepository
implements PostConfigurableRepository, MutableQuietPeriodAwareRepository, WebRepositoryEnabledRepository

This class provides a Perforce implemention of the Repository interface.

See Also:
Serialized Form

Field Summary
static java.lang.String BAD_FORMAT
           
static java.lang.String KEY
           
static java.lang.String NAME
           
static java.lang.String P4_CAPABILITY_KEY
           
static java.lang.String P4_CLIENT
           
static java.lang.String P4_DEPOT
           
static java.lang.String P4_MANAGE
           
static java.lang.String P4_PASSWD
           
static java.lang.String P4_PORT
           
static java.lang.String P4_USER
           
 
Fields inherited from class com.atlassian.bamboo.repository.AbstractRepository
BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, CLEAN_CHECKOUT_PARAM, repositoryModuleDescriptor, templateRenderer, textProvider, variableSubstitutionBean, WEB_REPO_MODULE_NAME, WEB_REPO_URL
 
Fields inherited from interface com.atlassian.bamboo.repository.Repository
SELECTED_REPOSITORY, UNKNOWN_HOST
 
Fields inherited from interface com.atlassian.bamboo.repository.IncludeExcludeAwareRepository
FILTER_PATTERN_EXCLUDE, FILTER_PATTERN_INCLUDE, FILTER_PATTERN_OPTION, FILTER_PATTERN_REGEX
 
Constructor Summary
PerforceRepository()
           
 
Method Summary
 void addDefaultValues(BuildConfiguration buildConfiguration)
          Extension point for adding default values to the form for #getEditHtml()
 BuildChanges collectChangesSinceLastBuild(java.lang.String planKey, java.lang.String lastVcsRevisionKey)
          Access the perforce repository to retrieve change logs since the lastVCSRevisionKey
 int compareTo(java.lang.Object obj)
           
 boolean equals(java.lang.Object o)
           
 void getAllSourceCode(Build build)
          Deprecated. 
 java.util.Collection<ChangeLogEntry> getChangesSinceLastBuild(Build build, java.util.Date lastBuildStartTime)
          Deprecated. 
 java.lang.String getClient()
          Obtain the perforce client we're using
 java.lang.String getDepot()
          What's the build depot that we're checking for changes?
 java.lang.String getEncryptedPassword()
          Whats the encryted password for the user
 java.lang.String getHost()
          Retrieves the address of the Perforce Server
 int getMaxRetries()
          Returns the maximum number of times to collect changes
 java.lang.String getName()
          Return the name of the repository
 java.lang.String getP4Executable()
          Which perforce p4 exe are we using?
 com.tek42.perforce.Depot getPerforceDepot()
          Retrieves an instance of a Perforce Depot populated with the builds information
 java.lang.String getPort()
          Which perforce server are we using?
 int getQuietPeriod()
          Returns the number of seconds to wait between each retry
 java.io.File getSourceCodeDirectory(java.lang.String planKey)
          Retrieves the location that the build will occur, If the workspace is managed this includes the source code directory specified by bamboo followed by the directory structure as indicated in the client view.
 java.lang.String getSubstitutedClient()
           
 java.lang.String getSubstitutedDepot()
           
 java.lang.String getSubstitutedPort()
           
 java.lang.String getSubstitutedUser()
           
 java.lang.String getSubstitutedWebRepositoryUrl()
          Return web repository URL with extrapolated Bamboo variables
 java.lang.String getUrl()
           
 java.lang.String getUser()
          What's the optional perforce user name? Returns null if we are not using a user
 java.lang.String getWebRepositoryUrl()
          What's the repository's web url
 java.lang.String getWebRepositoryUrlForDiff(CommitFile file)
           
 java.lang.String getWebRepositoryUrlForFile(CommitFile file)
          What's the URL to the repostory for the modified file?
 java.lang.String getWebRepositoryUrlForRevision(CommitFile file)
           
 java.lang.String getWebRepositoryUrlRepoName()
          What's the repository's web url repository
 int hashCode()
           
 boolean hasWebBasedRepositoryAccess()
          Does this recpository provdide a web url intereface?
 boolean isManageWorkspace()
           
 boolean isPerforceExecutableSet()
          For configuration screens
 boolean isQuietPeriodEnabled()
          Returns true if we were to enable the quiet period
 boolean isRepositoryDifferent(Repository repository)
          Checks if the current repo is the same or not and sets the referencesDifferentRepository flag accordingly
 void performPostConfiguration(BuildConfiguration buildConfiguration, Build build)
          Allows any other configuration to be performed after another repository has been created.
 void performPostConfigurationForSelectedRepository(BuildConfiguration buildConfiguration, Build build)
          Allows any other configuration to be performed after this repository has been created
 void populateFromConfig(org.apache.commons.configuration.HierarchicalConfiguration config)
          Update the current object with data in the HierarchicalConfiguration
 void prepareConfigObject(BuildConfiguration buildConfiguration)
          Do any preprocessing work before validation occurs
 java.lang.String retrieveSourceCode(java.lang.String planKey, java.lang.String vcsRevisionKey)
          Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from head
 void setCapabilityContext(CapabilityContext capabilityContext)
           
 void setClient(java.lang.String client)
          Define the client we're using to connect to the perforce server
 void setDepot(java.lang.String depot)
          Define the build depot
 void setEncryptedPassword(java.lang.String encryptedPassword)
          Set the password for the user.
 void setManageWorkspace(boolean manageWorkspace)
           
 void setMaxRetries(int maxRetries)
           
protected  void setP4Executable(java.lang.String p4Exe)
          Set the user specify which p4 executable we're using Should only be used for test purposes
 void setPerforceManager(PerforceManager perforceManager)
           
 void setPort(java.lang.String port)
          Define the perforce server and port we're going to connect to
 void setQuietPeriod(int quietPeriod)
           
 void setQuietPeriodEnabled(boolean quietPeriodEnabled)
           
 void setUser(java.lang.String user)
          Override the default user, if you want to specify the perforce user
 void setWebRepositoryUrl(java.lang.String myWebUrl)
          Where should we link to to show build file changes?
 void setWebRepositoryUrlRepoName(java.lang.String myWebModule)
          This is used to identify the repository on multi-repository configurations.
 void setWorkingDir(java.io.File workingDir)
          Ignore in as perforce will determine the working directory based on the client information
 org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
          Generate a HierarchicalConfiguration from the current state of the object
 ErrorCollection validate(BuildConfiguration buildConfiguration)
          Validates the properties in the BuildConfiguration object.
 
Methods inherited from class com.atlassian.bamboo.repository.AbstractRepository
checkConnection, createStringFromList, customizeBuildRequirements, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getTriggerIpAddress, getVariableSubstitutionBean, getViewHtml, getWebRepositoryUrlForCommit, getWorkingDirectory, init, isCleanCheckout, isWorkspaceEmpty, referencesDifferentRepository, setBuildDirectoryManager, setBuildLoggerManager, setCleanCheckout, setFilterFilePatternOption, setFilterFilePatternRegex, setReferencesDifferentRepository, setTemplateRenderer, setTextProvider, setTriggerIpAddress, setVariableSubstitutionBean
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.bamboo.repository.Repository
checkConnection, getKey, getTriggerIpAddress, setReferencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.repository.RepositoryV2
referencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, getEditHtml, getViewHtml, init
 
Methods inherited from interface com.atlassian.bamboo.repository.WebRepositoryEnabledRepository
getWebRepositoryUrlForCommit
 

Field Detail

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

KEY

public static final java.lang.String KEY
See Also:
Constant Field Values

P4_PORT

public static final java.lang.String P4_PORT
See Also:
Constant Field Values

P4_CLIENT

public static final java.lang.String P4_CLIENT
See Also:
Constant Field Values

P4_DEPOT

public static final java.lang.String P4_DEPOT
See Also:
Constant Field Values

P4_USER

public static final java.lang.String P4_USER
See Also:
Constant Field Values

P4_PASSWD

public static final java.lang.String P4_PASSWD
See Also:
Constant Field Values

P4_MANAGE

public static final java.lang.String P4_MANAGE
See Also:
Constant Field Values

BAD_FORMAT

public static final java.lang.String BAD_FORMAT
See Also:
Constant Field Values

P4_CAPABILITY_KEY

public static final java.lang.String P4_CAPABILITY_KEY
See Also:
Constant Field Values
Constructor Detail

PerforceRepository

public PerforceRepository()
Method Detail

collectChangesSinceLastBuild

@NotNull
public BuildChanges collectChangesSinceLastBuild(@NotNull
                                                         java.lang.String planKey,
                                                         @NotNull
                                                         java.lang.String lastVcsRevisionKey)
                                          throws RepositoryException
Access the perforce repository to retrieve change logs since the lastVCSRevisionKey

Specified by:
collectChangesSinceLastBuild in interface RepositoryV2
Parameters:
planKey -
lastVcsRevisionKey - - the revision number for the last build
Returns:
Build Changes with the change logs and the current revision key
Throws:
RepositoryException - If perforce fails to collect the changes

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   java.lang.String planKey,
                                                   @Nullable
                                                   java.lang.String vcsRevisionKey)
                                    throws RepositoryException
Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from head

Specified by:
retrieveSourceCode in interface RepositoryV2
Parameters:
planKey - - for the build being checked out
vcsRevisionKey - - the revision to checkout the source from
Returns:
the revision key of the checkout (only changes if checked out from head)
Throws:
RepositoryException - if Perforce fails to

getPerforceDepot

@NotNull
public com.tek42.perforce.Depot getPerforceDepot()
Retrieves an instance of a Perforce Depot populated with the builds information

Returns:

getP4Executable

@Nullable
public java.lang.String getP4Executable()
Which perforce p4 exe are we using?

Returns:
The location of the exe

validate

@NotNull
public ErrorCollection validate(@NotNull
                                        BuildConfiguration buildConfiguration)
Description copied from interface: ConfigurablePlugin
Validates the properties in the BuildConfiguration object. The name of the properties match those passed in through the form fragments in #getEditHtml() template.

Specified by:
validate in interface ConfigurablePlugin
Overrides:
validate in class AbstractRepository
Parameters:
buildConfiguration - - @NotNull
Returns:
ErrorCollection keyed by the field name. @NotNull

performPostConfiguration

public void performPostConfiguration(BuildConfiguration buildConfiguration,
                                     Build build)
Description copied from interface: PostConfigurableRepository
Allows any other configuration to be performed after another repository has been created.

Specified by:
performPostConfiguration in interface PostConfigurableRepository

performPostConfigurationForSelectedRepository

public void performPostConfigurationForSelectedRepository(BuildConfiguration buildConfiguration,
                                                          Build build)
Description copied from interface: PostConfigurableRepository
Allows any other configuration to be performed after this repository has been created

Specified by:
performPostConfigurationForSelectedRepository in interface PostConfigurableRepository

setP4Executable

protected void setP4Executable(java.lang.String p4Exe)
Set the user specify which p4 executable we're using Should only be used for test purposes

Parameters:
p4Exe - The locataion of the perforce p4 app (eg /usr/local/bin)

getClient

public java.lang.String getClient()
Obtain the perforce client we're using

Returns:
the client

getSubstitutedClient

public java.lang.String getSubstitutedClient()

setClient

public void setClient(java.lang.String client)
Define the client we're using to connect to the perforce server

Parameters:
client - The client

getPort

public java.lang.String getPort()
Which perforce server are we using?

Returns:
The perforce server (they call it port for some strange reason)

getSubstitutedPort

public java.lang.String getSubstitutedPort()

setPort

public void setPort(java.lang.String port)
Define the perforce server and port we're going to connect to

Parameters:
port - The perforce server and port

getDepot

public java.lang.String getDepot()
What's the build depot that we're checking for changes?

Returns:
the build

getSubstitutedDepot

public java.lang.String getSubstitutedDepot()

setDepot

public void setDepot(java.lang.String depot)
Define the build depot

Parameters:
depot - The depot

setUser

public void setUser(java.lang.String user)
Override the default user, if you want to specify the perforce user

Parameters:
user - The perforce user

getUser

public java.lang.String getUser()
What's the optional perforce user name? Returns null if we are not using a user

Returns:
The perforce user

getSubstitutedUser

public java.lang.String getSubstitutedUser()

isManageWorkspace

public boolean isManageWorkspace()

setManageWorkspace

public void setManageWorkspace(boolean manageWorkspace)

setEncryptedPassword

public void setEncryptedPassword(java.lang.String encryptedPassword)
Set the password for the user. This password should be encrypted

Parameters:
encryptedPassword -

getEncryptedPassword

public java.lang.String getEncryptedPassword()
Whats the encryted password for the user

Returns:
encrypted password

getName

@NotNull
public java.lang.String getName()
Return the name of the repository

Specified by:
getName in interface Repository
Returns:
String name of the repository

getWebRepositoryUrlRepoName

public java.lang.String getWebRepositoryUrlRepoName()
Description copied from interface: WebRepositoryEnabledRepository
What's the repository's web url repository

Specified by:
getWebRepositoryUrlRepoName in interface WebRepositoryEnabledRepository
Returns:
The repository (only used in multi-build repositories). Null if not used.

setWebRepositoryUrlRepoName

public void setWebRepositoryUrlRepoName(java.lang.String myWebModule)
Description copied from interface: WebRepositoryEnabledRepository
This is used to identify the repository on multi-repository configurations.

Specified by:
setWebRepositoryUrlRepoName in interface WebRepositoryEnabledRepository
Parameters:
myWebModule - The name of the repository we are viewing

getWebRepositoryUrl

public java.lang.String getWebRepositoryUrl()
Description copied from interface: WebRepositoryEnabledRepository
What's the repository's web url

Specified by:
getWebRepositoryUrl in interface WebRepositoryEnabledRepository
Returns:
The url

getSubstitutedWebRepositoryUrl

public java.lang.String getSubstitutedWebRepositoryUrl()
Return web repository URL with extrapolated Bamboo variables

Returns:
Web repository URL with extrapolated Bamboo variables

hasWebBasedRepositoryAccess

public boolean hasWebBasedRepositoryAccess()
Description copied from interface: WebRepositoryEnabledRepository
Does this recpository provdide a web url intereface?

Specified by:
hasWebBasedRepositoryAccess in interface WebRepositoryEnabledRepository
Returns:
true if we can link changes to the repositories web interface.

setWebRepositoryUrl

public void setWebRepositoryUrl(java.lang.String myWebUrl)
Description copied from interface: WebRepositoryEnabledRepository
Where should we link to to show build file changes?

Specified by:
setWebRepositoryUrl in interface WebRepositoryEnabledRepository
Parameters:
myWebUrl - The url of the repositories web interface

getUrl

public java.lang.String getUrl()

setWorkingDir

public void setWorkingDir(java.io.File workingDir)
Ignore in as perforce will determine the working directory based on the client information

Overrides:
setWorkingDir in class AbstractRepository
Parameters:
workingDir - ignored

getSourceCodeDirectory

@NotNull
public java.io.File getSourceCodeDirectory(@NotNull
                                                   java.lang.String planKey)
                                    throws RepositoryException
Retrieves the location that the build will occur, If the workspace is managed this includes the source code directory specified by bamboo followed by the directory structure as indicated in the client view. If the workspace is not manages this will include the root directory as specified the perforce client definition followed by the directory structure as indicated in the client view. This is not validated in any way.

Specified by:
getSourceCodeDirectory in interface RepositoryV2
Overrides:
getSourceCodeDirectory in class AbstractRepository
Parameters:
planKey -
Returns:
The location of the perforce build files
Throws:
RepositoryException - if it can not connect to perforce, could not find appropriate directory or the depot string is incorrect.

getWebRepositoryUrlForFile

public java.lang.String getWebRepositoryUrlForFile(CommitFile file)
Description copied from interface: WebRepositoryEnabledRepository
What's the URL to the repostory for the modified file?

Specified by:
getWebRepositoryUrlForFile in interface WebRepositoryEnabledRepository
Parameters:
file - The file that has been modified
Returns:
The url

getWebRepositoryUrlForDiff

public java.lang.String getWebRepositoryUrlForDiff(CommitFile file)

getWebRepositoryUrlForRevision

public java.lang.String getWebRepositoryUrlForRevision(CommitFile file)

getHost

public java.lang.String getHost()
Retrieves the address of the Perforce Server

Specified by:
getHost in interface Repository
Returns:
string host information

isRepositoryDifferent

public boolean isRepositoryDifferent(@NotNull
                                     Repository repository)
Description copied from interface: Repository
Checks if the current repo is the same or not and sets the referencesDifferentRepository flag accordingly

Specified by:
isRepositoryDifferent in interface Repository

getAllSourceCode

@Deprecated
public void getAllSourceCode(Build build)
                      throws RepositoryException
Deprecated. 

Force perforce to checkout all the source code. The -f flag is required so that even if the src dir has been deleted locally, P4 still d/l the source files again.

Parameters:
build -
Throws:
RepositoryException - Something went wrong

getChangesSinceLastBuild

@Deprecated
public java.util.Collection<ChangeLogEntry> getChangesSinceLastBuild(Build build,
                                                                                java.util.Date lastBuildStartTime)
                                                              throws RepositoryException
Deprecated. 

What changes to the build depot have happened since the given lastBuild?

Parameters:
build -
lastBuildStartTime - the date we are checking from
Returns:
A collection of ChangeLogEntry objects.
Throws:
RepositoryException - A generic failure

addDefaultValues

public void addDefaultValues(@NotNull
                             BuildConfiguration buildConfiguration)
Description copied from interface: ConfigurablePlugin
Extension point for adding default values to the form for #getEditHtml()

Specified by:
addDefaultValues in interface ConfigurablePlugin
Overrides:
addDefaultValues in class AbstractRepository
Parameters:
buildConfiguration - - @NotNull

populateFromConfig

public void populateFromConfig(@NotNull
                               org.apache.commons.configuration.HierarchicalConfiguration config)
Description copied from interface: ConvertibleFromConfig
Update the current object with data in the HierarchicalConfiguration

Specified by:
populateFromConfig in interface ConvertibleFromConfig
Overrides:
populateFromConfig in class AbstractRepository

toConfiguration

@NotNull
public org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
Description copied from interface: ConvertibleFromConfig
Generate a HierarchicalConfiguration from the current state of the object

Specified by:
toConfiguration in interface ConvertibleFromConfig
Overrides:
toConfiguration in class AbstractRepository
Returns:
Always returns an HierarchicalConfiguration. Never null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)

prepareConfigObject

public void prepareConfigObject(@NotNull
                                BuildConfiguration buildConfiguration)
Description copied from interface: ConfigurablePlugin
Do any preprocessing work before validation occurs

Specified by:
prepareConfigObject in interface ConfigurablePlugin
Parameters:
buildConfiguration - - @NotNull

isPerforceExecutableSet

public boolean isPerforceExecutableSet()
For configuration screens

Returns:
true if perforce capability is set and exists

isQuietPeriodEnabled

public boolean isQuietPeriodEnabled()
Description copied from interface: QuietPeriodAwareRepository
Returns true if we were to enable the quiet period

Specified by:
isQuietPeriodEnabled in interface QuietPeriodAwareRepository
Returns:

setQuietPeriodEnabled

public void setQuietPeriodEnabled(boolean quietPeriodEnabled)
Specified by:
setQuietPeriodEnabled in interface MutableQuietPeriodAwareRepository

getQuietPeriod

public int getQuietPeriod()
Description copied from interface: QuietPeriodAwareRepository
Returns the number of seconds to wait between each retry

Specified by:
getQuietPeriod in interface QuietPeriodAwareRepository
Returns:
seconds between retries

setQuietPeriod

public void setQuietPeriod(int quietPeriod)
Specified by:
setQuietPeriod in interface MutableQuietPeriodAwareRepository

getMaxRetries

public int getMaxRetries()
Description copied from interface: QuietPeriodAwareRepository
Returns the maximum number of times to collect changes

Specified by:
getMaxRetries in interface QuietPeriodAwareRepository
Returns:

setMaxRetries

public void setMaxRetries(int maxRetries)
Specified by:
setMaxRetries in interface MutableQuietPeriodAwareRepository

setPerforceManager

public void setPerforceManager(PerforceManager perforceManager)

setCapabilityContext

public void setCapabilityContext(CapabilityContext capabilityContext)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.