public class HgRepository extends AbstractStandaloneRepository implements AdvancedConfigurationAwareRepository, BranchInformationProvider, BranchMergingAwareRepository, CacheHandler, CachingAwareRepository, CommitIsolationAwareRepository, CustomSourceDirectoryAwareRepository, CustomVariableProviderRepository, DeploymentAwareRepository, EditActionAwareRepository, HgRepositoryFacade, MavenPomAccessorCapableRepository, PushCapableRepository, RequirementsAwareRepository, SharedCredentialDepender, ScmTypePublishingRepository, TestConnectionAwareRepository, UniqueRevisionIdRepository
CachingAwareRepository.CachableOperation
Modifier and Type | Field and Description |
---|---|
HgRepositoryAccessData |
accessData |
static Pattern |
branchesPattern |
static String |
DEFAULT_BRANCH |
static Duration |
DEFAULT_COMMAND_TIMEOUT |
administrationConfigurationAccessor, BUILD_TRIGGER_IP, buildDirectoryManager, buildLoggerManager, customVariableContext, featureManager, REPO_PREFIX, repositoryModuleDescriptor, templateRenderer, textProvider
moduleDescriptor
SELECTED_REPOSITORY, UNKNOWN_HOST
COMMIT_ISOLATION_OPTION
HOST_KEY
FILTER_PATTERN_EXCLUDE, FILTER_PATTERN_INCLUDE, FILTER_PATTERN_NONE, FILTER_PATTERN_OPTION, FILTER_PATTERN_REGEX
CHANGESET_FILTER_PATTERN_REGEX, MAVEN_RELEASE_PLUGIN_EXCLUSION_PATTERN
Constructor and Description |
---|
HgRepository() |
Modifier and Type | Method and Description |
---|---|
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) |
void |
beforeEditPageRendering(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Action to be taken before rendering the edit page.
|
ErrorCollection |
beforeSave(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Action to be taken before repository is saved from the UI.
|
static String |
branchOrDefault(String branch) |
BuildRepositoryChanges |
collectChangesForRevision(PlanKey planKey,
String targetRevision)
Collects the changes for the targetRevision.
|
BuildRepositoryChanges |
collectChangesSinceLastBuild(String planKey,
String lastVcsRevisionKey)
Collects the changes since the lastVcsRevisionKey.
|
String |
commit(File sourceDirectory,
String message)
Perform a commit (dvcs commit).
|
void |
deleteCaches(Collection<String> keys,
com.opensymphony.xwork.ValidationAware feedback)
Delete the specified caches, handling internal data updates etc.
|
void |
deleteUnusedCaches(com.opensymphony.xwork.ValidationAware feedback)
Delete all unused caches.
|
HgRepositoryAccessData |
getAccessData()
Returns raw access data: - repositoryUrl/branch/username are not substituted - password/sshKey/sshPassphrase are
not decrypted
|
static File |
getCacheBaseDirectory(BuildDirectoryManager buildDirectoryManager)
Separate static method so we can define the cache base directory in one place
|
Collection<CacheDescription> |
getCacheDescriptions()
Collection of cache descriptions to be displayed in the admin UI.
|
File |
getCacheDirectory() |
static File |
getCacheDirectory(File baseDirectory,
String repositoryUrl,
String username) |
CacheId |
getCacheId(CachingAwareRepository.CachableOperation cachableOperation)
Cache id has to fulfill the following:
Given two Repository objects A and B, returning equal CacheId (in terms of equals()) and a cachable operation foo(),
in the following sequence of calls made in a short time period:
1.
|
Map<String,String> |
getCustomVariables()
Return a map containing name->value mapping of the variables.
|
CommitContext |
getFirstCommit()
Retrieve the commit that created the Branch.
|
String |
getHandlerDescription()
Additional information about this cache type that would be displayed in UI.
|
String |
getHgExeCapability() |
HgRepository |
getHgRepository() |
String |
getHost()
What's the repository server host
|
CommitContext |
getLastCommit()
Retrieve last commit on the branch set on this Repository.
|
String |
getLocationIdentifier()
A string representing the location of the repository
|
MavenPomAccessor |
getMavenPomAccessor() |
protected int |
getMaxCommitsToReturn() |
String |
getName()
The display name for the repository type
|
List<VcsBranch> |
getOpenBranches(String context)
Set of open branches that are discovered in the repository. |
String |
getOptionDescription() |
List<ImmutablePlan> |
getOtherPlansSharingCache(Plan current) |
Map<String,String> |
getPlanRepositoryVariables()
Return a map containing name->value mapping of the plan repository format variables.
|
URI |
getRemoteUri() |
Set<Requirement> |
getRequirements() |
String |
getScm()
Get a string representing the name of the repository type.
|
Iterable<Long> |
getSharedCredentialIds()
Returns a list of shared credential ids used by this class.
|
String |
getSshExeCapability() |
HgRepositoryAccessData |
getSubstitutedAccessData()
Returns processed access data: - repositoryUrl/branch/username are substituted - password/sshKey/sshPassphrase
are decrypted - username/password are extracted from repositoryUrl if not set explicitly
|
HgRepositoryUIHelper |
getUIHelper()
Implementation of
AbstractStandaloneRepository.getAdvancedEditHtml(org.apache.commons.configuration.HierarchicalConfiguration) prevents us from customizing the context |
VcsBranch |
getVcsBranch() |
void |
init(com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
Initialises the Plugin with the plugin module descriptor
|
boolean |
isCachingSupportedFor(CachingAwareRepository.CachableOperation cachableOperation) |
boolean |
isCommitIsolationEnabled()
Whether or not commits will be broken up into individual builds
|
boolean |
isHgExecutableSet()
For configuration screens
|
boolean |
isMergingSupported() |
List<BuildRepositoryChanges> |
isolateCommits(BuildRepositoryChanges buildChanges)
Break the single build changes object into a list of
BuildRepositoryChanges . |
boolean |
isRepositoryDifferent(Repository repository)
Checks if the current repo is the same as the given repository
|
boolean |
isSharedCredentialsDeleted() |
protected boolean |
isWorkspaceEmpty(File sourceCodeDirectory) |
boolean |
mergeWorkspaceWith(BuildContext buildContext,
File workspace,
String targetRevision)
Merges a workspace located in checkout directory with the target revision.
|
void |
populateFromConfig(org.apache.commons.configuration.HierarchicalConfiguration hierarchicalConfiguration)
Update the current object with data in the
HierarchicalConfiguration |
void |
prepareConfigObject(BuildConfiguration buildConfiguration)
Do any preprocessing work before validation occurs.
|
void |
pushRevision(File sourceDirectory,
String vcsRevisionKey)
Push the specified revision to the remote directory.
|
String |
retrieveSourceCode(BuildContext buildContext,
String vcsRevisionKey,
File sourceDirectory)
Checks out the latest source code from an appropriate repository to specified directory
|
String |
retrieveSourceCode(BuildContext buildContext,
String vcsRevisionKey,
File sourceDirectory,
int depth)
So far mercurial cannot retrieve a "shallow" clone of repository so we're ignoring depth argument
|
void |
setBranchIntegrationHelper(VcsBranchIntegrationHelper branchIntegrationHelper)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setCapabilityContext(CapabilityContext capabilityContext)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setCommitIsolationEnabled(boolean commitIsolationEnabled) |
void |
setCredentialsAccessor(CredentialsAccessor credentialsAccessor)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setHgCacheHandler(HgCacheHandler hgCacheHandler)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setHgRepositoryUIHelper(HgRepositoryUIHelper hgRepositoryUIHelper)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setHgRepositoryValidator(HgRepositoryValidator hgRepositoryValidator)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setScopedExclusionService(ScopedExclusionService scopedExclusionService)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setSshProxyService(SshProxyService sshProxyService)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setTrustedKeyHelper(TrustedKeyHelper trustedKeyHelper)
Deprecated.
since 6.8 use constructor injection or annotation injection
|
void |
setVcsBranch(VcsBranch branch)
Set and prepare the repository for using an arbitrary branch.
|
ErrorCollection |
testConnection(long timeout,
TimeUnit unit)
Test connection to the repository within the given timeout.
|
org.apache.commons.configuration.HierarchicalConfiguration |
toConfiguration()
Generate a
HierarchicalConfiguration from the current state of the object |
boolean |
usePollingForBranchDetection()
If Bamboo generic detection polling should be used for this repository
|
ErrorCollection |
validate(BuildConfiguration buildConfiguration)
Validates the properties in the
BuildConfiguration object. |
ErrorCollection |
validateForConnectionTesting(BuildConfiguration buildConfiguration)
A method similar to
BuildConfigurationAwarePlugin.validate(BuildConfiguration) used to validate repository configuration
before connection testing. |
getAdvancedEditHtml, getAdvancedViewHtml, getEditHtml, getViewHtml, getViewHtml
checkConnection, customizeBuildRequirements, getAdvancedEditHtml, getAdvancedViewHtml, getBranchIntegrationEditHtml, getChangesetFilterPatternRegex, getDefaultTriggerModule, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getMavenPomCheckoutAccessEditHtml, getMaxRetries, getMinimalEditHtml, getPollingTriggerModule, getQuietPeriod, getShortKey, getSourceCodeDirectory, getSystemWideExclusionPatterns, getViewHtml, getWorkingDirectory, isAdvancedOptionEnabled, isQuietPeriodEnabled, removeBuildRequirements, setAdministrationConfigurationAccessor, setBuildDirectoryManager, setBuildLoggerManager, setChangesetFilterPatternRegex, setCustomVariableContext, setFeatureManager, setFilterFilePatternOption, setFilterFilePatternRegex, setTemplateRenderer, setTextProvider, setWorkingDir, substituteString, toMergeCapableRepository
populateContextForEdit, populateContextForView
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAdvancedEditHtml, getAdvancedViewHtml
checkConnection, getKey, getMinimalEditHtml, getShortKey
getSourceCodeDirectory
customizeBuildRequirements, removeBuildRequirements
isConfigurationMissing
getEditHtml, getViewHtml
getDescription
getBranchIntegrationEditHtml
getKey
public static final String DEFAULT_BRANCH
public static final Duration DEFAULT_COMMAND_TIMEOUT
public static final Pattern branchesPattern
public HgRepositoryAccessData accessData
public void init(@NotNull com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
InitablePluginModule
init
in interface InitablePluginModule
init
in class AbstractRepository
moduleDescriptor
- Plugin module descriptor@NotNull public String getName()
Repository
getName
in interface CacheHandler
getName
in interface Repository
getName
in interface DescriptionProvider
getName
in interface NameProvider
public String getHost()
Repository
getHost
in interface Repository
@NotNull public String getLocationIdentifier()
Repository
getLocationIdentifier
in interface Repository
getLocationIdentifier
in class AbstractRepository
public boolean isRepositoryDifferent(@NotNull Repository repository)
RepositoryV2
isRepositoryDifferent
in interface RepositoryV2
repository
- to compare against@NotNull public File getCacheDirectory()
public static File getCacheBaseDirectory(BuildDirectoryManager buildDirectoryManager)
buildDirectoryManager
- buildDirectoryManager to get the locations fromDeleteHgCacheDirectoryOnAgentMessage
@NotNull public static File getCacheDirectory(File baseDirectory, String repositoryUrl, @Nullable String username)
@NotNull public String commit(@NotNull File sourceDirectory, @NotNull String message) throws RepositoryException
PushCapableRepository
commit
in interface PushCapableRepository
sourceDirectory
- - which workspace directory to perform the commitmessage
- - what message use for commitRepositoryException
- - when something goes wrongpublic void pushRevision(@NotNull File sourceDirectory, @Nullable String vcsRevisionKey) throws RepositoryException
PushCapableRepository
pushRevision
in interface PushCapableRepository
sourceDirectory
- - the working directory of the repository we want to push fromvcsRevisionKey
- - the revisionKey (usually a branch name) to pushRepositoryException
- - when something goes wrong@NotNull public List<VcsBranch> getOpenBranches(@Nullable String context) throws RepositoryException
BranchDetectionCapableRepository
Set
of open branches that are discovered in the repository. Returns empty collection if no branches at
all (can that happen?). Used for monitoring repositories for new branches.
An open branch is a branch that is considered 'open' by underlying VCS - it has nothing to do with the actual
development on that branch (recent commits or so).getOpenBranches
in interface BranchDetectionCapableRepository
List
of branch names. May be empty.RepositoryException
public CacheId getCacheId(@NotNull CachingAwareRepository.CachableOperation cachableOperation)
CachingAwareRepository
getCacheId
in interface CachingAwareRepository
public boolean isCachingSupportedFor(@NotNull CachingAwareRepository.CachableOperation cachableOperation)
isCachingSupportedFor
in interface CachingAwareRepository
@NotNull public VcsBranch getVcsBranch()
getVcsBranch
in interface BranchAwareRepository
public void setVcsBranch(@NotNull VcsBranch branch)
BranchAwareRepository
setVcsBranch
in interface BranchAwareRepository
public CommitContext getLastCommit() throws RepositoryException
BranchDetectionCapableRepository
getLastCommit
in interface BranchDetectionCapableRepository
RepositoryException
public CommitContext getFirstCommit() throws RepositoryException
BranchDetectionCapableRepository
getFirstCommit
in interface BranchDetectionCapableRepository
RepositoryException
protected int getMaxCommitsToReturn()
getMaxCommitsToReturn
in class AbstractRepository
@NotNull public BuildRepositoryChanges collectChangesSinceLastBuild(@NotNull String planKey, @Nullable String lastVcsRevisionKey) throws RepositoryException
RepositoryV2
collectChangesSinceLastBuild
in interface RepositoryV2
lastVcsRevisionKey
- can be null, if null you should ensure the correct vcsrevisionkey is returned in the BuildChanges object.RepositoryException
- if something goes wrong@NotNull public BuildRepositoryChanges collectChangesForRevision(@NotNull PlanKey planKey, @NotNull String targetRevision) throws RepositoryException
OnceOffCapableRepository
collectChangesForRevision
in interface OnceOffCapableRepository
collectChangesForRevision
in class AbstractRepository
RepositoryException
- if something goes wrong@NotNull public String retrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey, @NotNull File sourceDirectory) throws RepositoryException
CustomSourceDirectoryAwareRepository
retrieveSourceCode
in interface CustomSourceDirectoryAwareRepository
vcsRevisionKey
- - may be null if you want latest codesourceDirectory
- - directory to checkout toRepositoryException
@NotNull public String retrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey, @NotNull File sourceDirectory, int depth) throws RepositoryException
retrieveSourceCode
in interface BranchMergingAwareRepository
vcsRevisionKey
- - may be null if you want latest codesourceDirectory
- - directory to checkout todepth
- - how many historical revisions we'd like to check out (-1 means all revisions)RepositoryException
public boolean mergeWorkspaceWith(@NotNull BuildContext buildContext, @NotNull File workspace, @NotNull String targetRevision) throws RepositoryException
BranchMergingAwareRepository
mergeWorkspaceWith
in interface BranchMergingAwareRepository
buildContext
- the build context of build doing the mergeworkspace
- the workspace to use for mergetargetRevision
- the revision to merge withRepositoryException
public boolean isMergingSupported()
isMergingSupported
in interface BranchMergingAwareRepository
@NotNull public Set<Requirement> getRequirements()
getRequirements
in interface RequirementsAwareRepository
public void addDefaultValues(@NotNull BuildConfiguration buildConfiguration)
BuildConfigurationAwarePlugin
RenderableBuildConfiguration.getEditHtml(com.atlassian.bamboo.ww2.actions.build.admin.create.BuildConfiguration, com.atlassian.bamboo.plan.Plan)
addDefaultValues
in interface BuildConfigurationAwarePlugin
addDefaultValues
in class AbstractRepository
buildConfiguration
- -public void prepareConfigObject(@NotNull BuildConfiguration buildConfiguration)
BuildConfigurationAwarePlugin
prepareConfigObject
in interface BuildConfigurationAwarePlugin
prepareConfigObject
in class BaseBuildConfigurationAwarePlugin
buildConfiguration
- -public void beforeEditPageRendering(@NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
EditActionAwareRepository
beforeEditPageRendering
in interface EditActionAwareRepository
configuration
- configuration to be loaded into the UIpublic ErrorCollection beforeSave(@NotNull org.apache.commons.configuration.HierarchicalConfiguration configuration)
EditActionAwareRepository
beforeSave
in interface EditActionAwareRepository
public void populateFromConfig(@NotNull org.apache.commons.configuration.HierarchicalConfiguration hierarchicalConfiguration)
ConvertibleFromConfig
HierarchicalConfiguration
populateFromConfig
in interface ConvertibleFromConfig
populateFromConfig
in class AbstractRepository
@NotNull public org.apache.commons.configuration.HierarchicalConfiguration toConfiguration()
ConvertibleFromConfig
HierarchicalConfiguration
from the current state of the objecttoConfiguration
in interface ConvertibleFromConfig
toConfiguration
in class AbstractRepository
HierarchicalConfiguration
. Never null@NotNull public Map<String,String> getCustomVariables()
CustomVariableProviderRepository
Null values will be filtered out so it's safe to put them in the map.
getCustomVariables
in interface CustomVariableProviderRepository
@NotNull public Map<String,String> getPlanRepositoryVariables()
CustomVariableProviderRepository
Null values will be filtered out so it's safe to put them in the map.
getPlanRepositoryVariables
in interface CustomVariableProviderRepository
@NotNull public ErrorCollection validateForConnectionTesting(@NotNull BuildConfiguration buildConfiguration)
TestConnectionAwareRepository
BuildConfigurationAwarePlugin.validate(BuildConfiguration)
used to validate repository configuration
before connection testing.
This method may be more relaxed than normal validation. Additionally, different error messages may be displayed
(e.g. related to impossibility of transferring files).validateForConnectionTesting
in interface TestConnectionAwareRepository
buildConfiguration
- repository configuration to validate@NotNull public ErrorCollection validate(@NotNull BuildConfiguration buildConfiguration)
BuildConfigurationAwarePlugin
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.validate
in interface BuildConfigurationAwarePlugin
validate
in class AbstractRepository
buildConfiguration
- -ErrorCollection
keyed by the field name.@NotNull public ErrorCollection testConnection(long timeout, @NotNull TimeUnit unit)
TestConnectionAwareRepository
testConnection
in interface TestConnectionAwareRepository
timeout
- the maximum time to waitunit
- the time unit of the timeout argument@NotNull public MavenPomAccessor getMavenPomAccessor()
getMavenPomAccessor
in interface MavenPomAccessorCapableRepository
protected boolean isWorkspaceEmpty(File sourceCodeDirectory)
isWorkspaceEmpty
in class AbstractRepository
@NotNull public String getHandlerDescription()
CacheHandler
This should include information about any non-obvious details like scheduling remote agent operations.
getHandlerDescription
in interface CacheHandler
@NotNull public Collection<CacheDescription> getCacheDescriptions()
CacheHandler
getCacheDescriptions
in interface CacheHandler
public void deleteCaches(@NotNull Collection<String> keys, @NotNull com.opensymphony.xwork.ValidationAware feedback)
CacheHandler
deleteCaches
in interface CacheHandler
keys
- keys from CacheDescription.getKey()
feedback
- consumer of UI messagespublic void deleteUnusedCaches(@NotNull com.opensymphony.xwork.ValidationAware feedback)
CacheHandler
It's the responsibility of the implementing class to figure out which caches are currently unused and optionally delete such caches on remote agents.
deleteUnusedCaches
in interface CacheHandler
feedback
- consumer of UI messages@NotNull public List<BuildRepositoryChanges> isolateCommits(@NotNull BuildRepositoryChanges buildChanges)
CommitIsolationAwareRepository
BuildRepositoryChanges
. Must not be null. May return an empty
list but that doesn't actually make any sense. BuildRepositoryChanges
will be more likely to be built than lower changes, which may be discarded.isolateCommits
in interface CommitIsolationAwareRepository
public boolean isCommitIsolationEnabled()
CommitIsolationAwareRepository
isCommitIsolationEnabled
in interface CommitIsolationAwareRepository
public void setCommitIsolationEnabled(boolean commitIsolationEnabled)
public HgRepositoryAccessData getAccessData()
public HgRepositoryAccessData getSubstitutedAccessData()
public boolean isHgExecutableSet()
@Nullable public String getHgExeCapability()
@Nullable public String getSshExeCapability()
@Nullable public URI getRemoteUri()
public List<ImmutablePlan> getOtherPlansSharingCache(Plan current)
public String getOptionDescription()
@Deprecated public void setBranchIntegrationHelper(VcsBranchIntegrationHelper branchIntegrationHelper)
@Deprecated public void setScopedExclusionService(ScopedExclusionService scopedExclusionService)
public boolean usePollingForBranchDetection()
BranchInformationProvider
usePollingForBranchDetection
in interface BranchInformationProvider
@Nullable public HgRepository getHgRepository()
getHgRepository
in interface HgRepositoryFacade
@NotNull public Iterable<Long> getSharedCredentialIds()
SharedCredentialDepender
getSharedCredentialIds
in interface SharedCredentialDepender
public boolean isSharedCredentialsDeleted()
public HgRepositoryUIHelper getUIHelper()
AbstractStandaloneRepository.getAdvancedEditHtml(org.apache.commons.configuration.HierarchicalConfiguration)
prevents us from customizing the context@Deprecated public void setCapabilityContext(CapabilityContext capabilityContext)
@Deprecated public void setCredentialsAccessor(CredentialsAccessor credentialsAccessor)
@Deprecated public void setHgCacheHandler(HgCacheHandler hgCacheHandler)
@Deprecated public void setHgRepositoryUIHelper(HgRepositoryUIHelper hgRepositoryUIHelper)
@Deprecated public void setHgRepositoryValidator(HgRepositoryValidator hgRepositoryValidator)
@Deprecated public void setI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)
@Deprecated public void setSshProxyService(SshProxyService sshProxyService)
@Deprecated public void setTrustedKeyHelper(TrustedKeyHelper trustedKeyHelper)
public String getScm()
ScmTypePublishingRepository
getScm
in interface ScmTypePublishingRepository
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.