com.atlassian.bamboo.repository.perforce
Class PerforceRepository

java.lang.Object
  extended by com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
      extended by com.atlassian.bamboo.v2.build.BaseConfigurablePlugin
          extended by com.atlassian.bamboo.repository.AbstractRepository
              extended by com.atlassian.bamboo.repository.perforce.PerforceRepository
All Implemented Interfaces:
ConvertibleFromConfig, InitablePluginModule, CleanCheckoutAwareRepository, CleanWorkingDirectoryAwareRepository, IncludeExcludeAwareRepository, MavenPomAccessorCapableRepository, QuietPeriodAwareRepository, Repository, DescriptionProvider, NameProvider, BambooPluginModule, BuildConfigurationAwarePlugin, ConfigurablePlugin, RenderableBuildConfiguration, PostConfigurableRepository, RepositoryV2, java.io.Serializable

public class PerforceRepository
extends AbstractRepository
implements PostConfigurableRepository, MavenPomAccessorCapableRepository

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 COMPLETE_PLUGIN_KEY
           
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_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH
           
static java.lang.String P4_PASSWD
           
static java.lang.String P4_PORT
           
static java.lang.String P4_USER
           
protected  PerforceManager perforceManager
           
static java.lang.String TEMPORARY_P4_PASSWORD
           
 
Fields inherited from class com.atlassian.bamboo.repository.AbstractRepository
BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, CLEAN_CHECKOUT_PARAM, CLEAN_WORKING_DIRECTORY_PARAM, customVariableContext, repositoryModuleDescriptor, templateRenderer, textProvider
 
Fields inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
moduleDescriptor
 
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 RenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
 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.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
 MavenPomAccessor getMavenPomAccessor()
           
 java.lang.String getMavenPomCheckoutPomRelativePath()
           
 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?
 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 getUrl()
           
 java.lang.String getUser()
          What's the optional perforce user name? Returns null if we are not using a user
 int hashCode()
           
 boolean isManageWorkspace()
           
 boolean isPerforceExecutableSet()
          For configuration screens
 boolean isRepositoryDifferent(Repository repository)
          Checks if the current repo is the same as the given repository
 void performPostConfiguration(BuildConfiguration buildConfiguration, Plan plan)
          Allows any other configuration to be performed after another repository has been created.
 void performPostConfigurationForSelectedRepository(BuildConfiguration buildConfiguration, Plan plan)
          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(BuildContext buildContext, java.lang.String vcsRevisionKey)
          Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from head
 java.lang.String retrieveSourceCode(java.lang.String planKey, java.lang.String vcsRevisionKey)
          Checks out the latest source code to an appropriate repository
 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 setMavenPomCheckoutPomRelativePath(java.lang.String mavenPomCheckoutPomRelativePath)
           
 void setPerforceManager(PerforceManager perforceManager)
           
 void setPort(java.lang.String port)
          Define the perforce server and port we're going to connect to
 void setUser(java.lang.String user)
          Override the default user, if you want to specify the perforce user
 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, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getLocationIdentifier, getMavenPomCheckoutAccessEditHtml, getMaxRetries, getMinimalEditHtml, getQuietPeriod, getShortKey, getSourceCodeDirectory, getTriggerIpAddress, getViewHtml, getWorkingDirectory, init, isCleanCheckout, isCleanWorkingDirectory, isQuietPeriodEnabled, isWorkspaceEmpty, referencesDifferentRepository, removeBuildRequirements, setBuildDirectoryManager, setBuildLoggerManager, setCleanCheckout, setCleanWorkingDirectory, setCustomVariableContext, setFilterFilePatternOption, setFilterFilePatternRegex, setReferencesDifferentRepository, setTemplateRenderer, setTextProvider, setTriggerIpAddress, substituteString
 
Methods inherited from class com.atlassian.bamboo.v2.build.BaseConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
Methods inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
isConfigurationMissing, populateContextForEdit, populateContextForView
 
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, getLocationIdentifier, getMinimalEditHtml, getShortKey, getTriggerIpAddress, setReferencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.repository.RepositoryV2
getSourceCodeDirectory, referencesDifferentRepository
 
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
Methods inherited from interface com.atlassian.bamboo.v2.build.RenderableBuildConfiguration
getEditHtml, getViewHtml
 
Methods inherited from interface com.atlassian.bamboo.utils.DescriptionProvider
getDescription
 

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

COMPLETE_PLUGIN_KEY

public static final java.lang.String COMPLETE_PLUGIN_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

P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH

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

TEMPORARY_P4_PASSWORD

public static final java.lang.String TEMPORARY_P4_PASSWORD
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

perforceManager

protected transient PerforceManager perforceManager
Constructor Detail

PerforceRepository

public PerforceRepository()
Method Detail

collectChangesSinceLastBuild

@NotNull
public BuildChanges collectChangesSinceLastBuild(@NotNull
                                                         java.lang.String planKey,
                                                         @Nullable
                                                         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
Description copied from interface: RepositoryV2
Checks out the latest source code to an appropriate repository

Specified by:
retrieveSourceCode in interface RepositoryV2
vcsRevisionKey - - may be null if you want latest code
Returns:
vcsRevisionKey - the revision
Throws:
RepositoryException

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   BuildContext buildContext,
                                                   @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:
buildContext - - 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

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: BuildConfigurationAwarePlugin
Validates the properties in the BuildConfiguration object. The name of the properties match those passed in through the form fragments in RenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan) template.

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

performPostConfiguration

public void performPostConfiguration(BuildConfiguration buildConfiguration,
                                     Plan plan)
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,
                                                          Plan plan)
Description copied from interface: PostConfigurableRepository
Allows any other configuration to be performed after this repository has been created

Specified by:
performPostConfigurationForSelectedRepository in interface PostConfigurableRepository

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

getMavenPomCheckoutPomRelativePath

public java.lang.String getMavenPomCheckoutPomRelativePath()

setMavenPomCheckoutPomRelativePath

public void setMavenPomCheckoutPomRelativePath(java.lang.String mavenPomCheckoutPomRelativePath)

getName

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

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

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.

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: RepositoryV2
Checks if the current repo is the same as the given repository

Specified by:
isRepositoryDifferent in interface RepositoryV2
Parameters:
repository - to compare against
Returns:
true of repositories are different, false if the same;

getMavenPomAccessor

@NotNull
public MavenPomAccessor getMavenPomAccessor()
Specified by:
getMavenPomAccessor in interface MavenPomAccessorCapableRepository

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

addDefaultValues

public void addDefaultValues(@NotNull
                             BuildConfiguration buildConfiguration)
Description copied from interface: BuildConfigurationAwarePlugin
Extension point for adding default values to the form for RenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)

Specified by:
addDefaultValues in interface BuildConfigurationAwarePlugin
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: BuildConfigurationAwarePlugin
Do any preprocessing work before validation occurs. For repository, builder and web repository plugins this will only be called if the plugin is select by the user.

Specified by:
prepareConfigObject in interface BuildConfigurationAwarePlugin
Overrides:
prepareConfigObject in class BaseBuildConfigurationAwarePlugin
Parameters:
buildConfiguration - - @NotNull

isPerforceExecutableSet

public boolean isPerforceExecutableSet()
For configuration screens

Returns:
true if perforce capability is set and exists

setPerforceManager

public void setPerforceManager(PerforceManager perforceManager)

setCapabilityContext

public void setCapabilityContext(CapabilityContext capabilityContext)


Copyright © 2011 Atlassian. All Rights Reserved.