Class PerforceRepository
- java.lang.Object
-
- com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
-
- com.atlassian.bamboo.v2.build.BaseConfigurablePlugin
-
- com.atlassian.bamboo.repository.AbstractRepository
-
- com.atlassian.bamboo.repository.AbstractStandaloneRepository
-
- com.atlassian.bamboo.repository.perforce.PerforceRepository
-
- All Implemented Interfaces:
ConvertibleFromConfig
,InitablePluginModule
,AdvancedConfigurationAwareRepository
,CustomVariableProviderRepository
,FilterChangesetAwareRepository
,IncludeExcludeAwareRepository
,MavenPomAccessorCapableRepository
,OnceOffCapableRepository
,QuietPeriodAwareRepository
,Repository
,StandaloneRepository
,DescriptionProvider
,NameProvider
,BambooPluginModule
,BuildConfigurationAwarePlugin
,ConfigurablePlugin
,RenderableBuildConfiguration
,LegacyRepository
,RepositoryV2
,RequirementsAwareRepository
,Serializable
public class PerforceRepository extends AbstractStandaloneRepository implements LegacyRepository, MavenPomAccessorCapableRepository, RequirementsAwareRepository, CustomVariableProviderRepository
This class provides a Perforce implementation of theRepository
interface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BAD_FORMAT
static String
COMPLETE_PLUGIN_KEY
static String
KEY
static String
NAME
static String
P4_CAPABILITY_KEY
static String
P4_CLIENT
static String
P4_DEPOT
static String
P4_EXTRA_ENVIRONMENT
static String
P4_MANAGE
static String
P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH
static String
P4_PASSWD
static String
P4_PORT
static String
P4_USECLIENTMAPPING
static String
P4_USER
protected PerforceManager
perforceManager
static String
TEMPORARY_P4_PASSWORD
-
Fields inherited from class com.atlassian.bamboo.repository.AbstractRepository
administrationConfigurationAccessor, BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, customVariableContext, featureManager, REPO_PREFIX, repositoryModuleDescriptor, templateRenderer, textProvider
-
Fields inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
moduleDescriptor
-
Fields inherited from interface com.atlassian.bamboo.repository.FilterChangesetAwareRepository
CHANGESET_FILTER_PATTERN_REGEX, MAVEN_RELEASE_PLUGIN_EXCLUSION_PATTERN
-
Fields inherited from interface com.atlassian.bamboo.repository.IncludeExcludeAwareRepository
FILTER_PATTERN_EXCLUDE, FILTER_PATTERN_INCLUDE, FILTER_PATTERN_NONE, FILTER_PATTERN_OPTION, FILTER_PATTERN_REGEX
-
Fields inherited from interface com.atlassian.bamboo.repository.Repository
SELECTED_REPOSITORY, UNKNOWN_HOST
-
-
Constructor Summary
Constructors Constructor Description PerforceRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefaultValues(@NotNull BuildConfiguration buildConfiguration)
Extension point for adding default values to the form forRenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
@NotNull BuildRepositoryChanges
collectChangesForRevision(@NotNull PlanKey planKey, @Nullable String targetRevision)
Collects the changes for the targetRevision.@NotNull BuildRepositoryChanges
collectChangesSinceLastBuild(@NotNull String planKey, @Nullable String lastVcsRevisionKey)
Access the perforce repository to retrieve change logs since the lastVCSRevisionKeyint
compareTo(Object obj)
boolean
equals(Object o)
String
getClient()
Obtain the perforce client we're using@NotNull Map<String,String>
getCustomVariables()
Return a map containing name->value mapping of the variables.String
getDepot()
What's the build depot that we're checking for changes?String
getEncryptedPassword()
Whats the encryted password for the userString
getEnvironmentVariables()
@NotNull String
getHost()
Retrieves the address of the Perforce Server@NotNull MavenPomAccessor
getMavenPomAccessor()
String
getMavenPomCheckoutPomRelativePath()
@NotNull String
getName()
Return the name of the repository@Nullable String
getP4Executable()
Which perforce p4 exe are we using?@NotNull com.tek42.perforce.Depot
getPerforceDepot()
Retrieves an instance of a Perforce Depot populated with the builds information@NotNull Map<String,String>
getPlanRepositoryVariables()
Return a map containing name->value mapping of the plan repository format variables.String
getPort()
Which perforce server are we using?@NotNull Set<Requirement>
getRequirements()
@NotNull File
getSourceCodeDirectory(@NotNull PlanKey planKey)
Retrieves the location that the build will occur.String
getSubstitutedClient()
String
getSubstitutedDepot()
String
getSubstitutedPort()
String
getSubstitutedUser()
String
getUrl()
String
getUser()
What's the optional perforce user name? Returns null if we are not using a userint
hashCode()
boolean
isManageWorkspace()
boolean
isPerforceExecutableSet()
For configuration screensboolean
isRepositoryDifferent(@NotNull Repository repository)
Checks if the current repo is the same as the given repositoryboolean
isUseClientMapping()
void
populateFromConfig(@NotNull org.apache.commons.configuration.HierarchicalConfiguration config)
Update the current object with data in theHierarchicalConfiguration
void
prepareConfigObject(@NotNull BuildConfiguration buildConfiguration)
Do any preprocessing work before validation occurs.@NotNull String
retrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey)
Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from headvoid
setCapabilityContext(CapabilityContext capabilityContext)
void
setClient(String client)
Define the client we're using to connect to the perforce servervoid
setDepot(String depot)
Define the build depotvoid
setEncryptedPassword(String encryptedPassword)
Set the password for the user.void
setEnvironmentVariableAccessor(EnvironmentVariableAccessor environmentVariableAccessor)
void
setEnvironmentVariables(String environmentVariables)
void
setManageWorkspace(boolean manageWorkspace)
void
setMavenPomCheckoutPomRelativePath(String mavenPomCheckoutPomRelativePath)
void
setPerforceManager(PerforceManager perforceManager)
void
setPort(String port)
Define the perforce server and port we're going to connect tovoid
setUseClientMapping(boolean useClientMapping)
void
setUser(String user)
Override the default user, if you want to specify the perforce uservoid
setWorkingDir(File workingDir)
Ignore in as perforce will determine the working directory based on the client information@NotNull org.apache.commons.configuration.HierarchicalConfiguration
toConfiguration()
Generate aHierarchicalConfiguration
from the current state of the object@NotNull ErrorCollection
validate(@NotNull BuildConfiguration buildConfiguration)
Validates the properties in theBuildConfiguration
object.-
Methods inherited from class com.atlassian.bamboo.repository.AbstractStandaloneRepository
getAdvancedEditHtml, getAdvancedViewHtml, getEditHtml, getViewHtml, getViewHtml
-
Methods inherited from class com.atlassian.bamboo.repository.AbstractRepository
checkConnection, customizeBuildRequirements, getAdvancedEditHtml, getAdvancedViewHtml, getBranchIntegrationEditHtml, getChangesetFilterPatternRegex, getDefaultTriggerModule, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getLocationIdentifier, getMavenPomCheckoutAccessEditHtml, getMaxCommitsToReturn, getMaxRetries, getMinimalEditHtml, getPollingTriggerModule, getQuietPeriod, getShortKey, getSystemWideExclusionPatterns, getViewHtml, getWorkingDirectory, init, isAdvancedOptionEnabled, isQuietPeriodEnabled, isWorkspaceEmpty, removeBuildRequirements, setAdministrationConfigurationAccessor, setBuildDirectoryManager, setBuildLoggerManager, setChangesetFilterPatternRegex, setCustomVariableContext, setFeatureManager, setFilterFilePatternOption, setFilterFilePatternRegex, setTemplateRenderer, setTextProvider, substituteString, toMergeCapableRepository
-
Methods inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
getTemplateRenderer, 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.v2.build.BuildConfigurationAwarePlugin
isConfigurationMissing
-
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
-
Methods inherited from interface com.atlassian.bamboo.utils.DescriptionProvider
getDescription
-
Methods inherited from interface com.atlassian.bamboo.plugin.InitablePluginModule
init
-
Methods inherited from interface com.atlassian.bamboo.v2.build.RenderableBuildConfiguration
getEditHtml, getViewHtml
-
Methods inherited from interface com.atlassian.bamboo.repository.Repository
checkConnection, getKey, getLocationIdentifier, getMinimalEditHtml, getShortKey
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
KEY
public static final String KEY
- See Also:
- Constant Field Values
-
COMPLETE_PLUGIN_KEY
public static final String COMPLETE_PLUGIN_KEY
- See Also:
- Constant Field Values
-
P4_PORT
public static final String P4_PORT
- See Also:
- Constant Field Values
-
P4_CLIENT
public static final String P4_CLIENT
- See Also:
- Constant Field Values
-
P4_DEPOT
public static final String P4_DEPOT
- See Also:
- Constant Field Values
-
P4_USER
public static final String P4_USER
- See Also:
- Constant Field Values
-
P4_PASSWD
public static final String P4_PASSWD
- See Also:
- Constant Field Values
-
P4_MANAGE
public static final String P4_MANAGE
- See Also:
- Constant Field Values
-
P4_USECLIENTMAPPING
public static final String P4_USECLIENTMAPPING
- See Also:
- Constant Field Values
-
P4_EXTRA_ENVIRONMENT
public static final String P4_EXTRA_ENVIRONMENT
- See Also:
- Constant Field Values
-
P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH
public static final String P4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATH
- See Also:
- Constant Field Values
-
TEMPORARY_P4_PASSWORD
public static final String TEMPORARY_P4_PASSWORD
- See Also:
- Constant Field Values
-
BAD_FORMAT
public static final String BAD_FORMAT
- See Also:
- Constant Field Values
-
P4_CAPABILITY_KEY
public static final String P4_CAPABILITY_KEY
- See Also:
- Constant Field Values
-
perforceManager
protected transient PerforceManager perforceManager
-
-
Method Detail
-
collectChangesForRevision
@NotNull public @NotNull BuildRepositoryChanges collectChangesForRevision(@NotNull @NotNull PlanKey planKey, @Nullable @Nullable String targetRevision) throws RepositoryException
Description copied from interface:OnceOffCapableRepository
Collects the changes for the targetRevision. This method is called only on server side (never on agent).- Specified by:
collectChangesForRevision
in interfaceOnceOffCapableRepository
- Overrides:
collectChangesForRevision
in classAbstractRepository
- Returns:
- A build changes object with the appropriate build changes (that is - with the single commit data relevant for targetRevision)
- Throws:
RepositoryException
- if something goes wrong
-
collectChangesSinceLastBuild
@NotNull public @NotNull BuildRepositoryChanges collectChangesSinceLastBuild(@NotNull @NotNull String planKey, @Nullable @Nullable String lastVcsRevisionKey) throws RepositoryException
Access the perforce repository to retrieve change logs since the lastVCSRevisionKey- Specified by:
collectChangesSinceLastBuild
in interfaceRepositoryV2
- 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 @NotNull String retrieveSourceCode(@NotNull @NotNull BuildContext buildContext, @Nullable @Nullable 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 interfaceLegacyRepository
- Parameters:
buildContext
- - for the build being checked outvcsRevisionKey
- - 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 @NotNull com.tek42.perforce.Depot getPerforceDepot()
Retrieves an instance of a Perforce Depot populated with the builds information- Returns:
-
getP4Executable
@Nullable public @Nullable String getP4Executable()
Which perforce p4 exe are we using?- Returns:
- The location of the exe
-
validate
@NotNull public @NotNull ErrorCollection validate(@NotNull @NotNull BuildConfiguration buildConfiguration)
Description copied from interface:BuildConfigurationAwarePlugin
Validates the properties in theBuildConfiguration
object. The name of the properties match those passed in through the form fragments inRenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
template.- Specified by:
validate
in interfaceBuildConfigurationAwarePlugin
- Overrides:
validate
in classAbstractRepository
- Parameters:
buildConfiguration
- -- Returns:
ErrorCollection
keyed by the field name.
-
getRequirements
@NotNull public @NotNull Set<Requirement> getRequirements()
- Specified by:
getRequirements
in interfaceRequirementsAwareRepository
-
getClient
public String getClient()
Obtain the perforce client we're using- Returns:
- the client
-
getSubstitutedClient
public String getSubstitutedClient()
-
setClient
public void setClient(String client)
Define the client we're using to connect to the perforce server- Parameters:
client
- The client
-
getPort
public String getPort()
Which perforce server are we using?- Returns:
- The perforce server (they call it port for some strange reason)
-
getSubstitutedPort
public String getSubstitutedPort()
-
setPort
public void setPort(String port)
Define the perforce server and port we're going to connect to- Parameters:
port
- The perforce server and port
-
getDepot
public String getDepot()
What's the build depot that we're checking for changes?- Returns:
- the build
-
getSubstitutedDepot
public String getSubstitutedDepot()
-
setDepot
public void setDepot(String depot)
Define the build depot- Parameters:
depot
- The depot
-
setUser
public void setUser(String user)
Override the default user, if you want to specify the perforce user- Parameters:
user
- The perforce user
-
getUser
public String getUser()
What's the optional perforce user name? Returns null if we are not using a user- Returns:
- The perforce user
-
getSubstitutedUser
public String getSubstitutedUser()
-
isManageWorkspace
public boolean isManageWorkspace()
-
setManageWorkspace
public void setManageWorkspace(boolean manageWorkspace)
-
isUseClientMapping
public boolean isUseClientMapping()
-
setUseClientMapping
public void setUseClientMapping(boolean useClientMapping)
-
getEnvironmentVariables
public String getEnvironmentVariables()
-
setEnvironmentVariables
public void setEnvironmentVariables(String environmentVariables)
-
setEncryptedPassword
public void setEncryptedPassword(String encryptedPassword)
Set the password for the user. This password should be encrypted- Parameters:
encryptedPassword
-
-
getEncryptedPassword
public String getEncryptedPassword()
Whats the encryted password for the user- Returns:
- encrypted password
-
getMavenPomCheckoutPomRelativePath
public String getMavenPomCheckoutPomRelativePath()
-
setMavenPomCheckoutPomRelativePath
public void setMavenPomCheckoutPomRelativePath(String mavenPomCheckoutPomRelativePath)
-
getName
@NotNull public @NotNull String getName()
Return the name of the repository- Specified by:
getName
in interfaceDescriptionProvider
- Specified by:
getName
in interfaceNameProvider
- Specified by:
getName
in interfaceRepository
- Returns:
- String name of the repository
-
getUrl
public String getUrl()
-
setWorkingDir
public void setWorkingDir(File workingDir)
Ignore in as perforce will determine the working directory based on the client information- Overrides:
setWorkingDir
in classAbstractRepository
- Parameters:
workingDir
- ignored
-
getSourceCodeDirectory
@NotNull public @NotNull File getSourceCodeDirectory(@NotNull @NotNull PlanKey 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 interfaceRepositoryV2
- Overrides:
getSourceCodeDirectory
in classAbstractRepository
- 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
@NotNull public @NotNull String getHost()
Retrieves the address of the Perforce Server- Specified by:
getHost
in interfaceRepository
- Returns:
- string host information
-
isRepositoryDifferent
public boolean isRepositoryDifferent(@NotNull @NotNull Repository repository)
Description copied from interface:RepositoryV2
Checks if the current repo is the same as the given repository- Specified by:
isRepositoryDifferent
in interfaceRepositoryV2
- Parameters:
repository
- to compare against- Returns:
- true of repositories are different, false if the same;
-
getMavenPomAccessor
@NotNull public @NotNull MavenPomAccessor getMavenPomAccessor()
- Specified by:
getMavenPomAccessor
in interfaceMavenPomAccessorCapableRepository
-
addDefaultValues
public void addDefaultValues(@NotNull @NotNull BuildConfiguration buildConfiguration)
Description copied from interface:BuildConfigurationAwarePlugin
Extension point for adding default values to the form forRenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
- Specified by:
addDefaultValues
in interfaceBuildConfigurationAwarePlugin
- Overrides:
addDefaultValues
in classAbstractRepository
- Parameters:
buildConfiguration
- -
-
populateFromConfig
public void populateFromConfig(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration config)
Description copied from interface:ConvertibleFromConfig
Update the current object with data in theHierarchicalConfiguration
- Specified by:
populateFromConfig
in interfaceConvertibleFromConfig
- Overrides:
populateFromConfig
in classAbstractRepository
-
toConfiguration
@NotNull public @NotNull org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
Description copied from interface:ConvertibleFromConfig
Generate aHierarchicalConfiguration
from the current state of the object- Specified by:
toConfiguration
in interfaceConvertibleFromConfig
- Overrides:
toConfiguration
in classAbstractRepository
- Returns:
- Always returns an
HierarchicalConfiguration
. Never null
-
getCustomVariables
@NotNull public @NotNull Map<String,String> getCustomVariables()
Description copied from interface:CustomVariableProviderRepository
Return a map containing name->value mapping of the variables.Null values will be filtered out so it's safe to put them in the map.
- Specified by:
getCustomVariables
in interfaceCustomVariableProviderRepository
- Returns:
- Map with variable substitutions
-
getPlanRepositoryVariables
@NotNull public @NotNull Map<String,String> getPlanRepositoryVariables()
Description copied from interface:CustomVariableProviderRepository
Return a map containing name->value mapping of the plan repository format variables.Null values will be filtered out so it's safe to put them in the map.
- Specified by:
getPlanRepositoryVariables
in interfaceCustomVariableProviderRepository
- Returns:
- Map with variable substitutions
-
compareTo
public int compareTo(Object obj)
-
prepareConfigObject
public void prepareConfigObject(@NotNull @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 interfaceBuildConfigurationAwarePlugin
- Overrides:
prepareConfigObject
in classBaseBuildConfigurationAwarePlugin
- Parameters:
buildConfiguration
- -
-
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)
-
setEnvironmentVariableAccessor
public void setEnvironmentVariableAccessor(EnvironmentVariableAccessor environmentVariableAccessor)
-
-