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 theRepositoryinterface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringBAD_FORMATstatic StringCOMPLETE_PLUGIN_KEYstatic StringKEYstatic StringNAMEstatic StringP4_CAPABILITY_KEYstatic StringP4_CLIENTstatic StringP4_DEPOTstatic StringP4_EXTRA_ENVIRONMENTstatic StringP4_MANAGEstatic StringP4_MAVEN_POM_CHECKOUT_POM_RELATIVE_PATHstatic StringP4_PASSWDstatic StringP4_PORTstatic StringP4_USECLIENTMAPPINGstatic StringP4_USERprotected PerforceManagerperforceManagerstatic StringTEMPORARY_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 voidaddDefaultValues(@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 BuildRepositoryChangescollectChangesForRevision(@NotNull PlanKey planKey, @Nullable String targetRevision)Collects the changes for the targetRevision.@NotNull BuildRepositoryChangescollectChangesSinceLastBuild(@NotNull String planKey, @Nullable String lastVcsRevisionKey)Access the perforce repository to retrieve change logs since the lastVCSRevisionKeyintcompareTo(Object obj)booleanequals(Object o)StringgetClient()Obtain the perforce client we're using@NotNull Map<String,String>getCustomVariables()Return a map containing name->value mapping of the variables.StringgetDepot()What's the build depot that we're checking for changes?StringgetEncryptedPassword()StringgetEnvironmentVariables()@NotNull StringgetHost()Retrieves the address of the Perforce Server@NotNull MavenPomAccessorgetMavenPomAccessor()StringgetMavenPomCheckoutPomRelativePath()@NotNull StringgetName()Return the name of the repository@Nullable StringgetP4Executable()Which perforce p4 exe are we using?@NotNull com.tek42.perforce.DepotgetPerforceDepot()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.StringgetPort()Which perforce server are we using?@NotNull Set<Requirement>getRequirements()@NotNull FilegetSourceCodeDirectory(@NotNull PlanKey planKey)Retrieves the location that the build will occur.StringgetSubstitutedClient()StringgetSubstitutedDepot()StringgetSubstitutedPort()StringgetSubstitutedUser()StringgetUrl()StringgetUser()What's the optional perforce user name?inthashCode()booleanisManageWorkspace()booleanisPerforceExecutableSet()For configuration screensbooleanisRepositoryDifferent(@NotNull Repository repository)Checks if the current repo is the same as the given repositorybooleanisUseClientMapping()voidpopulateFromConfig(@NotNull org.apache.commons.configuration.HierarchicalConfiguration config)Update the current object with data in theHierarchicalConfigurationvoidprepareConfigObject(@NotNull BuildConfiguration buildConfiguration)Do any preprocessing work before validation occurs.@NotNull StringretrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey)Checkout the sourcecode as at the vcsRevisionKey, if revisionKey is null source will be checked out from headvoidsetCapabilityContext(CapabilityContext capabilityContext)voidsetClient(String client)Define the client we're using to connect to the perforce servervoidsetDepot(String depot)Define the build depotvoidsetEncryptedPassword(String encryptedPassword)Set the password for the user.voidsetEnvironmentVariableAccessor(EnvironmentVariableAccessor environmentVariableAccessor)voidsetEnvironmentVariables(String environmentVariables)voidsetManageWorkspace(boolean manageWorkspace)voidsetMavenPomCheckoutPomRelativePath(String mavenPomCheckoutPomRelativePath)voidsetPerforceManager(PerforceManager perforceManager)voidsetPort(String port)Define the perforce server and port we're going to connect tovoidsetUseClientMapping(boolean useClientMapping)voidsetUser(String user)Override the default user, if you want to specify the perforce uservoidsetWorkingDir(File workingDir)Ignore in as perforce will determine the working directory based on the client information@NotNull org.apache.commons.configuration.HierarchicalConfigurationtoConfiguration()Generate aHierarchicalConfigurationfrom the current state of the object@NotNull ErrorCollectionvalidate(@NotNull BuildConfiguration buildConfiguration)Validates the properties in theBuildConfigurationobject.-
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:OnceOffCapableRepositoryCollects the changes for the targetRevision. This method is called only on server side (never on agent).- Specified by:
collectChangesForRevisionin interfaceOnceOffCapableRepository- Overrides:
collectChangesForRevisionin 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:
collectChangesSinceLastBuildin 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:
retrieveSourceCodein 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:BuildConfigurationAwarePluginValidates the properties in theBuildConfigurationobject. 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:
validatein interfaceBuildConfigurationAwarePlugin- Overrides:
validatein classAbstractRepository- Parameters:
buildConfiguration- -- Returns:
ErrorCollectionkeyed by the field name.
-
getRequirements
@NotNull public @NotNull Set<Requirement> getRequirements()
- Specified by:
getRequirementsin 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()
- 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:
getNamein interfaceDescriptionProvider- Specified by:
getNamein interfaceNameProvider- Specified by:
getNamein 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:
setWorkingDirin 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:
getSourceCodeDirectoryin interfaceRepositoryV2- Overrides:
getSourceCodeDirectoryin 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:
getHostin interfaceRepository- Returns:
- string host information
-
isRepositoryDifferent
public boolean isRepositoryDifferent(@NotNull @NotNull Repository repository)Description copied from interface:RepositoryV2Checks if the current repo is the same as the given repository- Specified by:
isRepositoryDifferentin interfaceRepositoryV2- Parameters:
repository- to compare against- Returns:
- true of repositories are different, false if the same;
-
getMavenPomAccessor
@NotNull public @NotNull MavenPomAccessor getMavenPomAccessor()
- Specified by:
getMavenPomAccessorin interfaceMavenPomAccessorCapableRepository
-
addDefaultValues
public void addDefaultValues(@NotNull @NotNull BuildConfiguration buildConfiguration)Description copied from interface:BuildConfigurationAwarePluginExtension 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:
addDefaultValuesin interfaceBuildConfigurationAwarePlugin- Overrides:
addDefaultValuesin classAbstractRepository- Parameters:
buildConfiguration- -
-
populateFromConfig
public void populateFromConfig(@NotNull @NotNull org.apache.commons.configuration.HierarchicalConfiguration config)Description copied from interface:ConvertibleFromConfigUpdate the current object with data in theHierarchicalConfiguration- Specified by:
populateFromConfigin interfaceConvertibleFromConfig- Overrides:
populateFromConfigin classAbstractRepository
-
toConfiguration
@NotNull public @NotNull org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
Description copied from interface:ConvertibleFromConfigGenerate aHierarchicalConfigurationfrom the current state of the object- Specified by:
toConfigurationin interfaceConvertibleFromConfig- Overrides:
toConfigurationin classAbstractRepository- Returns:
- Always returns an
HierarchicalConfiguration. Never null
-
getCustomVariables
@NotNull public @NotNull Map<String,String> getCustomVariables()
Description copied from interface:CustomVariableProviderRepositoryReturn 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:
getCustomVariablesin interfaceCustomVariableProviderRepository- Returns:
- Map with variable substitutions
-
getPlanRepositoryVariables
@NotNull public @NotNull Map<String,String> getPlanRepositoryVariables()
Description copied from interface:CustomVariableProviderRepositoryReturn 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:
getPlanRepositoryVariablesin interfaceCustomVariableProviderRepository- Returns:
- Map with variable substitutions
-
compareTo
public int compareTo(Object obj)
-
prepareConfigObject
public void prepareConfigObject(@NotNull @NotNull BuildConfiguration buildConfiguration)Description copied from interface:BuildConfigurationAwarePluginDo 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:
prepareConfigObjectin interfaceBuildConfigurationAwarePlugin- Overrides:
prepareConfigObjectin 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)
-
-