com.atlassian.bamboo.plugins.git
Class GitHubRepository

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.AbstractStandaloneRepository
                  extended by com.atlassian.bamboo.plugins.git.GitHubRepository
All Implemented Interfaces:
ConvertibleFromConfig, InitablePluginModule, GitRepositoryFacade, AdvancedConfigurationAwareRepository, BranchAwareRepository, BranchDetectionCapableRepository, BranchInformationProvider, BranchMergingAwareRepository, CachingAwareRepository, DeploymentAwareRepository, FilterChangesetAwareRepository, IncludeExcludeAwareRepository, OnceOffCapableRepository, PushCapableRepository, QuietPeriodAwareRepository, Repository, StandaloneRepository, DescriptionProvider, NameProvider, BambooPluginModule, BuildConfigurationAwarePlugin, ConfigurablePlugin, RenderableBuildConfiguration, CustomSourceDirectoryAwareRepository, RepositoryV2, java.io.Serializable

public class GitHubRepository
extends AbstractStandaloneRepository
implements AdvancedConfigurationAwareRepository, BranchInformationProvider, BranchMergingAwareRepository, CachingAwareRepository, CustomSourceDirectoryAwareRepository, DeploymentAwareRepository, GitRepositoryFacade, PushCapableRepository

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
administrationConfigurationManager, 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.Repository
SELECTED_REPOSITORY, UNKNOWN_HOST
 
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_OPTION, FILTER_PATTERN_REGEX
 
Fields inherited from interface com.atlassian.bamboo.repository.FilterChangesetAwareRepository
CHANGESET_FILTER_PATTERN_REGEX, MAVEN_RELEASE_PLUGIN_EXCLUSION_PATTERN
 
Constructor Summary
GitHubRepository()
           
 
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)
 BuildRepositoryChanges collectChangesForRevision(PlanKey planKey, java.lang.String targetRevision)
          Collects the changes for the targetRevision.
 BuildRepositoryChanges collectChangesSinceLastBuild(java.lang.String planKey, java.lang.String lastVcsRevisionKey)
          Collects the changes since the lastVcsRevisionKey.
 java.lang.String commit(java.io.File file, java.lang.String s)
          Perform a commit (dvcs commit).
 GitHubRepositoryAccessData getAccessData()
           
 java.lang.String getBranch()
           
 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.
 int getCommandTimeout()
           
 java.lang.String getEncryptedPassword()
           
 CommitContext getFirstCommit()
          Retrieve the commit that created the Branch.
 GitRepository getGitRepository()
           
 java.lang.String getHost()
          What's the repository server host
 CommitContext getLastCommit()
          Retrieve last commit on the branch set on this Repository.
 java.lang.String getName()
          The display name for the repository type
 java.util.List<VcsBranch> getOpenBranches()
          Deprecated. 
 java.util.List<VcsBranch> getOpenBranches(java.lang.String context)
          Set of open branches that are discovered in the repository.
 java.lang.String getOptionDescription()
           
 java.lang.String getRepository()
           
 java.lang.String getUsername()
           
 VcsBranch getVcsBranch()
           
 boolean getVerboseLogs()
           
 boolean isCachingSupportedFor(CachingAwareRepository.CachableOperation cachableOperation)
           
 boolean isMergingSupported()
           
 boolean isRepositoryDifferent(Repository repository)
          Checks if the current repo is the same as the given repository
 boolean isUseShallowClones()
           
 boolean isUseSubmodules()
           
 boolean mergeWorkspaceWith(BuildContext buildContext, java.io.File file, java.lang.String s)
          Merges a workspace located in checkout directory with the target revision.
 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.
 void pushRevision(java.io.File file, java.lang.String s)
          Push the specified revision to the remote directory.
 java.lang.String retrieveSourceCode(BuildContext buildContext, java.lang.String vcsRevision)
           
 java.lang.String retrieveSourceCode(BuildContext buildContext, java.lang.String vcsRevisionKey, java.io.File sourceDirectory)
          Checks out the latest source code from an appropriate repository to specified directory
 java.lang.String retrieveSourceCode(BuildContext buildContext, java.lang.String vcsRevisionKey, java.io.File sourceDirectory, int depth)
          Checks out the latest source code from an appropriate repository to specified directory
 void setAccessData(GitHubRepositoryAccessData gitHubAccessData)
           
 void setBranchIntegrationHelper(BranchIntegrationHelper branchIntegrationHelper)
           
 void setBuildDirectoryManager(BuildDirectoryManager buildDirectoryManager)
           
 void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)
           
 void setCapabilityContext(CapabilityContext capabilityContext)
           
 void setCustomVariableContext(CustomVariableContext customVariableContext)
           
 void setEncryptionService(EncryptionService encryptionService)
           
 void setI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)
           
 void setSshProxyService(SshProxyService sshProxyService)
           
 void setTemplateRenderer(TemplateRenderer templateRenderer)
           
 void setVcsBranch(VcsBranch vcsBranch)
          Set and prepare the repository for using an arbitrary branch.
 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.
 
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, getDefaultBuildStrategy, getDescription, getEditHtml, getFilterFilePatternOption, getFilterFilePatternRegex, getKey, getLocationIdentifier, getMavenPomCheckoutAccessEditHtml, getMaxCommitsToReturn, getMaxRetries, getMinimalEditHtml, getQuietPeriod, getShortKey, getSourceCodeDirectory, getSystemWideExclusionPatterns, getViewHtml, getWorkingDirectory, init, isAdvancedOptionEnabled, isQuietPeriodEnabled, isWorkspaceEmpty, removeBuildRequirements, setAdministrationConfigurationManager, setChangesetFilterPatternRegex, setFeatureManager, setFilterFilePatternOption, setFilterFilePatternRegex, setTextProvider, setWorkingDir, substituteString, toMergeCapableRepository
 
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, 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.Repository
checkConnection, getKey, getLocationIdentifier, getMinimalEditHtml, getShortKey
 
Methods inherited from interface com.atlassian.bamboo.v2.build.repository.RepositoryV2
getSourceCodeDirectory
 
Methods inherited from interface com.atlassian.bamboo.v2.build.ConfigurablePlugin
customizeBuildRequirements, removeBuildRequirements
 
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.utils.DescriptionProvider
getDescription
 
Methods inherited from interface com.atlassian.bamboo.repository.BranchMergingAwareRepository
getBranchIntegrationEditHtml
 

Constructor Detail

GitHubRepository

public GitHubRepository()
Method Detail

setBuildDirectoryManager

public void setBuildDirectoryManager(BuildDirectoryManager buildDirectoryManager)
Overrides:
setBuildDirectoryManager in class AbstractRepository

setBuildLoggerManager

public void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)
Overrides:
setBuildLoggerManager in class AbstractRepository

setI18nResolver

public void setI18nResolver(com.atlassian.sal.api.message.I18nResolver i18nResolver)

setEncryptionService

public void setEncryptionService(EncryptionService encryptionService)

setCustomVariableContext

public void setCustomVariableContext(CustomVariableContext customVariableContext)
Overrides:
setCustomVariableContext in class AbstractRepository

setCapabilityContext

public void setCapabilityContext(CapabilityContext capabilityContext)

setSshProxyService

public void setSshProxyService(SshProxyService sshProxyService)

setBranchIntegrationHelper

public void setBranchIntegrationHelper(BranchIntegrationHelper branchIntegrationHelper)

setTemplateRenderer

public void setTemplateRenderer(TemplateRenderer templateRenderer)
Overrides:
setTemplateRenderer in class AbstractRepository

getName

@NotNull
public java.lang.String getName()
Description copied from interface: Repository
The display name for the repository type

Specified by:
getName in interface Repository
Specified by:
getName in interface DescriptionProvider
Specified by:
getName in interface NameProvider

getHost

public java.lang.String getHost()
Description copied from interface: Repository
What's the repository server host

Specified by:
getHost in interface Repository
Returns:
The host!

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;

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

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

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

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

collectChangesForRevision

@NotNull
public BuildRepositoryChanges collectChangesForRevision(@NotNull
                                                                PlanKey planKey,
                                                                @NotNull
                                                                java.lang.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 interface OnceOffCapableRepository
Overrides:
collectChangesForRevision in class AbstractRepository
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 BuildRepositoryChanges collectChangesSinceLastBuild(@NotNull
                                                                   java.lang.String planKey,
                                                                   @Nullable
                                                                   java.lang.String lastVcsRevisionKey)
                                                    throws RepositoryException
Description copied from interface: RepositoryV2
Collects the changes since the lastVcsRevisionKey. This method is called only on server side (never on agent).

Specified by:
collectChangesSinceLastBuild in interface RepositoryV2
lastVcsRevisionKey - 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 java.lang.String retrieveSourceCode(@NotNull
                                                   BuildContext buildContext,
                                                   @Nullable
                                                   java.lang.String vcsRevision)
                                    throws RepositoryException
Throws:
RepositoryException

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   BuildContext buildContext,
                                                   @Nullable
                                                   java.lang.String vcsRevisionKey,
                                                   @NotNull
                                                   java.io.File sourceDirectory)
                                    throws RepositoryException
Description copied from interface: CustomSourceDirectoryAwareRepository
Checks out the latest source code from an appropriate repository to specified directory

Specified by:
retrieveSourceCode in interface CustomSourceDirectoryAwareRepository
vcsRevisionKey - - may be null if you want latest code
sourceDirectory - - directory to checkout to
Returns:
vcsRevisionKey - the revision
Throws:
RepositoryException

retrieveSourceCode

@NotNull
public java.lang.String retrieveSourceCode(@NotNull
                                                   BuildContext buildContext,
                                                   @Nullable
                                                   java.lang.String vcsRevisionKey,
                                                   @NotNull
                                                   java.io.File sourceDirectory,
                                                   int depth)
                                    throws RepositoryException
Description copied from interface: BranchMergingAwareRepository
Checks out the latest source code from an appropriate repository to specified directory

Specified by:
retrieveSourceCode in interface BranchMergingAwareRepository
vcsRevisionKey - - may be null if you want latest code
sourceDirectory - - directory to checkout to
depth - - how many historical revisions we'd like to check out (-1 means all revisions)
Returns:
vcsRevisionKey - the revision
Throws:
RepositoryException

getUsername

public java.lang.String getUsername()

getRepository

public java.lang.String getRepository()

getBranch

public java.lang.String getBranch()

isUseShallowClones

public boolean isUseShallowClones()

getEncryptedPassword

public java.lang.String getEncryptedPassword()

isUseSubmodules

public boolean isUseSubmodules()

getCommandTimeout

public int getCommandTimeout()

getVerboseLogs

public boolean getVerboseLogs()

getOpenBranches

@NotNull
@Deprecated
public java.util.List<VcsBranch> getOpenBranches()
                                          throws RepositoryException
Deprecated. 

Throws:
RepositoryException

getOpenBranches

@NotNull
public java.util.List<VcsBranch> getOpenBranches(@Nullable
                                                         java.lang.String context)
                                          throws RepositoryException
Description copied from interface: 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).

Specified by:
getOpenBranches in interface BranchDetectionCapableRepository
Returns:
List of branch names. May be empty.
Throws:
RepositoryException

getVcsBranch

@NotNull
public VcsBranch getVcsBranch()
Specified by:
getVcsBranch in interface BranchAwareRepository
Returns:
the branch being used currently by this repository.

setVcsBranch

public void setVcsBranch(@NotNull
                         VcsBranch vcsBranch)
Description copied from interface: BranchAwareRepository
Set and prepare the repository for using an arbitrary branch. Generally the subsequent getVcsBranch should return the same branch name.

Specified by:
setVcsBranch in interface BranchAwareRepository

getCacheId

public CacheId getCacheId(@NotNull
                          CachingAwareRepository.CachableOperation cachableOperation)
Description copied from interface: CachingAwareRepository
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. 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:
getCacheId in interface CachingAwareRepository
Returns:
the cache id of repository, null if the supplied operation cannot be cached

isCachingSupportedFor

public boolean isCachingSupportedFor(@NotNull
                                     CachingAwareRepository.CachableOperation cachableOperation)
Specified by:
isCachingSupportedFor in interface CachingAwareRepository
Returns:
true if the repository supports generation of CacheIds for a given operation

getLastCommit

public CommitContext getLastCommit()
                            throws RepositoryException
Description copied from interface: BranchDetectionCapableRepository
Retrieve 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:
getLastCommit in interface BranchDetectionCapableRepository
Returns:
the last commit or null if N/A
Throws:
RepositoryException

getFirstCommit

public CommitContext getFirstCommit()
                             throws RepositoryException
Description copied from interface: BranchDetectionCapableRepository
Retrieve the commit that created the Branch.

Specified by:
getFirstCommit in interface BranchDetectionCapableRepository
Returns:
the first commit to the branch
Throws:
RepositoryException

mergeWorkspaceWith

public boolean mergeWorkspaceWith(@NotNull
                                  BuildContext buildContext,
                                  @NotNull
                                  java.io.File file,
                                  @NotNull
                                  java.lang.String s)
                           throws RepositoryException
Description copied from interface: BranchMergingAwareRepository
Merges a workspace located in checkout directory with the target revision.

Specified by:
mergeWorkspaceWith in interface BranchMergingAwareRepository
Parameters:
buildContext - the build context of build doing the merge
file - the workspace to use for merge
s - 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:
isMergingSupported in interface BranchMergingAwareRepository

pushRevision

public void pushRevision(@NotNull
                         java.io.File file,
                         @Nullable
                         java.lang.String s)
                  throws RepositoryException
Description copied from interface: PushCapableRepository
Push the specified revision to the remote directory. Throws RepositoryException when failed due to connection problems or similar.

Specified by:
pushRevision in interface PushCapableRepository
Parameters:
file - - the working directory of the repository we want to push from
s - - the revisionKey (usually a branch name) to push
Throws:
RepositoryException - - when something goes wrong

commit

@NotNull
public java.lang.String commit(@NotNull
                                       java.io.File file,
                                       @NotNull
                                       java.lang.String s)
                        throws RepositoryException
Description copied from interface: PushCapableRepository
Perform a commit (dvcs commit).

Specified by:
commit in interface PushCapableRepository
Parameters:
file - - which workspace directory to perform the commit
s - - what message use for commit
Returns:
Created commit revision key
Throws:
RepositoryException - - when something goes wrong

getOptionDescription

public java.lang.String getOptionDescription()

getAccessData

public GitHubRepositoryAccessData getAccessData()

setAccessData

public void setAccessData(GitHubRepositoryAccessData gitHubAccessData)

getGitRepository

public GitRepository getGitRepository()
Specified by:
getGitRepository in interface GitRepositoryFacade

usePollingForBranchDetection

public boolean usePollingForBranchDetection()
Description copied from interface: BranchInformationProvider
If Bamboo generic detection polling should be used for this repository

Specified by:
usePollingForBranchDetection in interface BranchInformationProvider
Returns:


Copyright © 2014 Atlassian Software Systems Pty Ltd. All Rights Reserved.