Package com.atlassian.bamboo.plugins.git
Class GitHubRepository
-
- All Implemented Interfaces:
ConvertibleFromConfig,InitablePluginModule,GitRepositoryFacade,AdvancedConfigurationAwareRepository,BranchAwareRepository,BranchDetectionCapableRepository,BranchInformationProvider,BranchMergingAwareRepository,CachingAwareRepository,CustomVariableProviderRepository,DeploymentAwareRepository,FilterChangesetAwareRepository,IncludeExcludeAwareRepository,OnceOffCapableRepository,PushCapableRepository,QuietPeriodAwareRepository,Repository,StandaloneRepository,UniqueRevisionIdRepository,DescriptionProvider,NameProvider,BambooPluginModule,BuildConfigurationAwarePlugin,ConfigurablePlugin,RenderableBuildConfiguration,CustomSourceDirectoryAwareRepository,RepositoryV2,Serializable
public class GitHubRepository extends AbstractStandaloneRepository implements AdvancedConfigurationAwareRepository, BranchInformationProvider, BranchMergingAwareRepository, CachingAwareRepository, CustomSourceDirectoryAwareRepository, CustomVariableProviderRepository, DeploymentAwareRepository, GitRepositoryFacade, PushCapableRepository, UniqueRevisionIdRepository
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.repository.CachingAwareRepository
CachingAwareRepository.CachableOperation
-
-
Field Summary
-
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.plugins.git.GitRepositoryFacade
GIT_REPOSITORIES_OF_PLAN
-
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 GitHubRepository()
-
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, @NotNull String targetRevision)Collects the changes for the targetRevision.@NotNull BuildRepositoryChangescollectChangesSinceLastBuild(@NotNull String planKey, @Nullable String lastVcsRevisionKey)Collects the changes since the lastVcsRevisionKey.@NotNull Stringcommit(@NotNull File file, @NotNull String s)Perform a commit (dvcs commit).GitHubRepositoryAccessDatagetAccessData()StringgetBaseUrl()StringgetBranch()CacheIdgetCacheId(@NotNull 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.intgetCommandTimeout()@NotNull Map<String,String>getCustomVariables()Return a map containing name->value mapping of the variables.CommitContextgetFirstCommit()Retrieve the commit that created the Branch.GitRepositorygetGitRepository()StringgetHost()What's the repository server hostCommitContextgetLastCommit()Retrieve last commit on the branch set on this Repository.@NotNull StringgetName()The display name for the repository type@NotNull List<VcsBranch>getOpenBranches(@Nullable String context)Setof open branches that are discovered in the repository.StringgetOptionDescription()StringgetPassword()@NotNull Map<String,String>getPlanRepositoryVariables()Return a map containing name->value mapping of the plan repository format variables.StringgetRepository()StringgetUsername()@NotNull VcsBranchgetVcsBranch()booleangetVerboseLogs()booleanisCachingSupportedFor(@NotNull CachingAwareRepository.CachableOperation cachableOperation)booleanisMergingSupported()booleanisRepositoryDifferent(@NotNull Repository repository)Checks if the current repo is the same as the given repositorybooleanisUseRemoteAgentCache()booleanisUseShallowClones()booleanisUseSubmodules()booleanmergeWorkspaceWith(@NotNull BuildContext buildContext, @NotNull File file, @NotNull String s)Merges a workspace located in checkout directory with the target revision.voidpopulateFromConfig(@NotNull org.apache.commons.configuration.HierarchicalConfiguration config)Update the current object with data in theHierarchicalConfigurationvoidpostConstruct()voidprepareConfigObject(@NotNull BuildConfiguration buildConfiguration)Do any preprocessing work before validation occurs.voidpushRevision(@NotNull File file, @Nullable String s)Push the specified revision to the remote directory.@NotNull StringretrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevision)@NotNull StringretrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey, @NotNull File sourceDirectory)Checks out the latest source code from an appropriate repository to specified directory@NotNull StringretrieveSourceCode(@NotNull BuildContext buildContext, @Nullable String vcsRevisionKey, @NotNull File sourceDirectory, int depth)Checks out the latest source code from an appropriate repository to specified directoryvoidsetAccessData(GitHubRepositoryAccessData gitHubAccessData)voidsetBranchIntegrationHelper(VcsBranchIntegrationHelper branchIntegrationHelper)voidsetBuildDirectoryManager(BuildDirectoryManager buildDirectoryManager)voidsetBuildLoggerManager(BuildLoggerManager buildLoggerManager)voidsetCapabilityContext(CapabilityContext capabilityContext)voidsetCustomVariableContext(CustomVariableContext customVariableContext)voidsetI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)voidsetSshProxyService(SshProxyService sshProxyService)voidsetTrustedKeyHelper(TrustedKeyHelper trustedKeyHelper)voidsetVcsBranch(@NotNull VcsBranch vcsBranch)Set and prepare the repository for using an arbitrary branch.@NotNull org.apache.commons.configuration.HierarchicalConfigurationtoConfiguration()Generate aHierarchicalConfigurationfrom the current state of the objectbooleanusePollingForBranchDetection()If Bamboo generic detection polling should be used for this repository@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, getSourceCodeDirectory, getSystemWideExclusionPatterns, getViewHtml, getWorkingDirectory, init, isAdvancedOptionEnabled, isQuietPeriodEnabled, isWorkspaceEmpty, removeBuildRequirements, setAdministrationConfigurationAccessor, setChangesetFilterPatternRegex, setFeatureManager, setFilterFilePatternOption, setFilterFilePatternRegex, setTemplateRenderer, setTextProvider, setWorkingDir, substituteString, toMergeCapableRepository
-
Methods inherited from class com.atlassian.bamboo.v2.build.BaseBuildConfigurationAwarePlugin
getTemplateRenderer, populateContextForEdit, populateContextForView
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.repository.AdvancedConfigurationAwareRepository
getAdvancedEditHtml, getAdvancedViewHtml
-
Methods inherited from interface com.atlassian.bamboo.repository.BranchMergingAwareRepository
getBranchIntegrationEditHtml
-
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
-
Methods inherited from interface com.atlassian.bamboo.v2.build.repository.RepositoryV2
getSourceCodeDirectory
-
-
-
-
Method Detail
-
setBuildDirectoryManager
public void setBuildDirectoryManager(BuildDirectoryManager buildDirectoryManager)
- Overrides:
setBuildDirectoryManagerin classAbstractRepository
-
setBuildLoggerManager
public void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)
- Overrides:
setBuildLoggerManagerin classAbstractRepository
-
setI18nResolver
public void setI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)
-
setTrustedKeyHelper
public void setTrustedKeyHelper(TrustedKeyHelper trustedKeyHelper)
-
setCustomVariableContext
public void setCustomVariableContext(CustomVariableContext customVariableContext)
- Overrides:
setCustomVariableContextin classAbstractRepository
-
setCapabilityContext
public void setCapabilityContext(CapabilityContext capabilityContext)
-
setSshProxyService
public void setSshProxyService(SshProxyService sshProxyService)
-
setBranchIntegrationHelper
public void setBranchIntegrationHelper(VcsBranchIntegrationHelper branchIntegrationHelper)
-
postConstruct
@PostConstruct public void postConstruct()
-
getName
@NotNull public @NotNull String getName()
Description copied from interface:RepositoryThe display name for the repository type- Specified by:
getNamein interfaceDescriptionProvider- Specified by:
getNamein interfaceNameProvider- Specified by:
getNamein interfaceRepository
-
getHost
public String getHost()
Description copied from interface:RepositoryWhat's the repository server host- Specified by:
getHostin interfaceRepository- Returns:
- The host!
-
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;
-
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- -
-
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- -
-
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
-
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.
-
collectChangesForRevision
@NotNull public @NotNull BuildRepositoryChanges collectChangesForRevision(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull 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
Description copied from interface:RepositoryV2Collects the changes since the lastVcsRevisionKey. This method is called only on server side (never on agent).- Specified by:
collectChangesSinceLastBuildin interfaceRepositoryV2lastVcsRevisionKey- can be null, if null you should ensure the correct vcsrevisionkey is returned in the BuildChanges object.- Returns:
- A build changes object with the appropriate build changes
- Throws:
RepositoryException- if something goes wrong
-
retrieveSourceCode
@NotNull public @NotNull String retrieveSourceCode(@NotNull @NotNull BuildContext buildContext, @Nullable @Nullable String vcsRevision) throws RepositoryException
- Throws:
RepositoryException
-
retrieveSourceCode
@NotNull public @NotNull String retrieveSourceCode(@NotNull @NotNull BuildContext buildContext, @Nullable @Nullable String vcsRevisionKey, @NotNull @NotNull File sourceDirectory) throws RepositoryException
Description copied from interface:CustomSourceDirectoryAwareRepositoryChecks out the latest source code from an appropriate repository to specified directory- Specified by:
retrieveSourceCodein interfaceCustomSourceDirectoryAwareRepositoryvcsRevisionKey- - may be null if you want latest codesourceDirectory- - directory to checkout to- Returns:
- vcsRevisionKey - the revision
- Throws:
RepositoryException
-
retrieveSourceCode
@NotNull public @NotNull String retrieveSourceCode(@NotNull @NotNull BuildContext buildContext, @Nullable @Nullable String vcsRevisionKey, @NotNull @NotNull File sourceDirectory, int depth) throws RepositoryException
Description copied from interface:BranchMergingAwareRepositoryChecks out the latest source code from an appropriate repository to specified directory- Specified by:
retrieveSourceCodein interfaceBranchMergingAwareRepositoryvcsRevisionKey- - 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)- Returns:
- vcsRevisionKey - the revision
- Throws:
RepositoryException
-
getUsername
public String getUsername()
-
getRepository
public String getRepository()
-
getBranch
public String getBranch()
-
isUseShallowClones
public boolean isUseShallowClones()
-
isUseRemoteAgentCache
public boolean isUseRemoteAgentCache()
-
getPassword
public String getPassword()
-
isUseSubmodules
public boolean isUseSubmodules()
-
getCommandTimeout
public int getCommandTimeout()
-
getVerboseLogs
public boolean getVerboseLogs()
-
getBaseUrl
public String getBaseUrl()
-
getOpenBranches
@NotNull public @NotNull List<VcsBranch> getOpenBranches(@Nullable @Nullable String context) throws RepositoryException
Description copied from interface:BranchDetectionCapableRepositorySetof 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).- Specified by:
getOpenBranchesin interfaceBranchDetectionCapableRepository- Returns:
Listof branch names. May be empty.- Throws:
RepositoryException
-
getVcsBranch
@NotNull public @NotNull VcsBranch getVcsBranch()
- Specified by:
getVcsBranchin interfaceBranchAwareRepository- Returns:
- the branch being used currently by this repository.
-
setVcsBranch
public void setVcsBranch(@NotNull @NotNull VcsBranch vcsBranch)Description copied from interface:BranchAwareRepositorySet and prepare the repository for using an arbitrary branch. Generally the subsequent getVcsBranch should return the same branch name.- Specified by:
setVcsBranchin interfaceBranchAwareRepository
-
getCacheId
public CacheId getCacheId(@NotNull @NotNull CachingAwareRepository.CachableOperation cachableOperation)
Description copied from interface:CachingAwareRepositoryCache 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. A::foo() 2. B::foo() 3. A::foo() the result of B::foo() should be the same as either the first or the second call to A::foo().- Specified by:
getCacheIdin interfaceCachingAwareRepository- Returns:
- the cache id of repository, null if the supplied operation cannot be cached
-
isCachingSupportedFor
public boolean isCachingSupportedFor(@NotNull @NotNull CachingAwareRepository.CachableOperation cachableOperation)- Specified by:
isCachingSupportedForin interfaceCachingAwareRepository- Returns:
- true if the repository supports generation of CacheIds for a given operation
-
getLastCommit
public CommitContext getLastCommit() throws RepositoryException
Description copied from interface:BranchDetectionCapableRepositoryRetrieve last commit on the branch set on this Repository. Method is used by Chain Branch automatic expiry. If this method returns null Chain Branch is not expired.- Specified by:
getLastCommitin interfaceBranchDetectionCapableRepository- Returns:
- the last commit or null if N/A
- Throws:
RepositoryException
-
getFirstCommit
public CommitContext getFirstCommit() throws RepositoryException
Description copied from interface:BranchDetectionCapableRepositoryRetrieve the commit that created the Branch.- Specified by:
getFirstCommitin interfaceBranchDetectionCapableRepository- Returns:
- the first commit to the branch
- Throws:
RepositoryException
-
mergeWorkspaceWith
public boolean mergeWorkspaceWith(@NotNull @NotNull BuildContext buildContext, @NotNull @NotNull File file, @NotNull @NotNull String s) throws RepositoryExceptionDescription copied from interface:BranchMergingAwareRepositoryMerges a workspace located in checkout directory with the target revision.- Specified by:
mergeWorkspaceWithin interfaceBranchMergingAwareRepository- Parameters:
buildContext- the build context of build doing the mergefile- the workspace to use for merges- the revision to merge with- Returns:
- true if the result of the merge would result in a non-empty commit
- Throws:
RepositoryException
-
isMergingSupported
public boolean isMergingSupported()
- Specified by:
isMergingSupportedin interfaceBranchMergingAwareRepository
-
pushRevision
public void pushRevision(@NotNull @NotNull File file, @Nullable @Nullable String s) throws RepositoryExceptionDescription copied from interface:PushCapableRepositoryPush the specified revision to the remote directory. Throws RepositoryException when failed due to connection problems or similar.- Specified by:
pushRevisionin interfacePushCapableRepository- Parameters:
file- - the working directory of the repository we want to push froms- - the revisionKey (usually a branch name) to push- Throws:
RepositoryException- - when something goes wrong
-
commit
@NotNull public @NotNull String commit(@NotNull @NotNull File file, @NotNull @NotNull String s) throws RepositoryException
Description copied from interface:PushCapableRepositoryPerform a commit (dvcs commit).- Specified by:
commitin interfacePushCapableRepository- Parameters:
file- - which workspace directory to perform the commits- - what message use for commit- Returns:
- Created commit revision key
- Throws:
RepositoryException- - when something goes wrong
-
getOptionDescription
public String getOptionDescription()
-
getAccessData
public GitHubRepositoryAccessData getAccessData()
-
setAccessData
public void setAccessData(GitHubRepositoryAccessData gitHubAccessData)
-
getGitRepository
public GitRepository getGitRepository()
- Specified by:
getGitRepositoryin interfaceGitRepositoryFacade
-
usePollingForBranchDetection
public boolean usePollingForBranchDetection()
Description copied from interface:BranchInformationProviderIf Bamboo generic detection polling should be used for this repository- Specified by:
usePollingForBranchDetectionin interfaceBranchInformationProvider- Returns:
-
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
-
-