Package hudson.plugins.git
Class GitSCM
- java.lang.Object
-
- hudson.scm.SCM
-
- hudson.plugins.git.GitSCMBackwardCompatibility
-
- hudson.plugins.git.GitSCM
-
- All Implemented Interfaces:
ExtensionPoint,Describable<SCM>,Serializable
public class GitSCM extends GitSCMBackwardCompatibility
Git SCM.- Author:
- Nigel Magnay, Andrew Bayer, Nicolas Deloof, Kohsuke Kawaguchi ... and many others
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGitSCM.DescriptorImpl-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static booleanALLOW_LOCAL_CHECKOUTstatic StringGIT_BRANCHstatic StringGIT_CHECKOUT_DIRstatic StringGIT_COMMITstatic StringGIT_LOCAL_BRANCHstatic StringGIT_PREVIOUS_COMMITstatic StringGIT_PREVIOUS_SUCCESSFUL_COMMITstatic PatternGIT_REFstatic StringGIT_URLStringgitToolstatic intMAX_CHANGELOGTo avoid pointlessly large changelog, we'll limit the number of changes up to this.static booleanVERBOSESet to true to enable more logging to build'sTaskListener.-
Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
-
-
Constructor Summary
Constructors Constructor Description GitSCM(String repositoryUrl)A convenience constructor that sets everything to default.GitSCM(List<UserRemoteConfig> userRemoteConfigs, List<BranchSpec> branches, GitRepositoryBrowser browser, String gitTool, List<GitSCMExtension> extensions)GitSCM(List<UserRemoteConfig> userRemoteConfigs, List<BranchSpec> branches, Boolean doGenerateSubmoduleConfigurations, Collection<SubmoduleConfig> submoduleCfg, GitRepositoryBrowser browser, String gitTool, List<GitSCMExtension> extensions)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbuildEnvironment(Run<?,?> build, Map<String,String> env)voidbuildEnvVars(AbstractBuild<?,?> build, Map<String,String> env)Deprecated.SCMRevisionStatecalcRevisionsFromBuild(Run<?,?> abstractBuild, FilePath workspace, Launcher launcher, TaskListener taskListener)voidcheckout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline)PollingResultcompareRemoteRevisionWith(Job<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline)static voidconfigureXtream()BuildDatacopyBuildData(Run build)LikegetBuildData(Run), but copy the data into a new object, which is used as the first step for updating the data for the next build.ChangeLogParsercreateChangeLogParser()org.jenkinsci.plugins.gitclient.GitClientcreateClient(TaskListener listener, EnvVars environment, Run<?,?> build, FilePath workspace)org.jenkinsci.plugins.gitclient.GitClientcreateClient(TaskListener listener, EnvVars environment, Run<?,?> build, FilePath workspace, org.jenkinsci.plugins.gitclient.UnsupportedCommand postBuildUnsupportedCommand)AllowsPublisherand other post build actions to access a configuredGitClient.static List<UserRemoteConfig>createRepoList(String url, String credentialsId)StringderiveLocalBranchName(String remoteBranchName)Derives a local branch name from the remote branch name by removing the name of the remote from the remote branch name.List<BranchSpec>getBranches()GitRepositoryBrowsergetBrowser()BuildChoosergetBuildChooser()BuildDatagetBuildData(Run build)Find the build log (BuildData) recorded with the last build that completed.BuildDatagetBuildData(Run build, boolean clone)Deprecated.booleangetDoGenerateSubmoduleConfigurations()Deprecated.DescribableList<GitSCMExtension,GitSCMExtensionDescriptor>getExtensions()All the configured extensions attached to thisGitSCM.StringgetGitExe(Node builtOn, EnvVars env, TaskListener listener)Exposing so that we can get this from GitPublisher.StringgetGitExe(Node builtOn, TaskListener listener)StringgetGitTool()hudson.plugins.git.GitToolgetGitTool(Node builtOn, EnvVars env, TaskListener listener)StringgetKey()PreBuildMergeOptionsgetMergeOptions()Deprecated.UsePreBuildMerge.static StringgetParameterString(String original, EnvVars env)org.eclipse.jgit.transport.RemoteConfiggetParamExpandedRepo(EnvVars env, org.eclipse.jgit.transport.RemoteConfig remoteRepository)Expand Parameters in the supplied remote repository with the parameter values provided in the given environment variablesList<org.eclipse.jgit.transport.RemoteConfig>getParamExpandedRepos(Run<?,?> build)Deprecated.List<org.eclipse.jgit.transport.RemoteConfig>getParamExpandedRepos(Run<?,?> build, TaskListener listener)Expand parameters inremoteRepositorieswith the parameter values provided in the given build and return them.StringgetParamLocalBranch(Run<?,?> build)Deprecated.StringgetParamLocalBranch(Run<?,?> build, TaskListener listener)Gets the parameter-expanded effective value in the context of the current build.List<org.eclipse.jgit.transport.RemoteConfig>getRepositories()org.eclipse.jgit.transport.RemoteConfiggetRepositoryByName(String repoName)Collection<SubmoduleConfig>getSubmoduleCfg()Deprecated.List<UserRemoteConfig>getUserRemoteConfigs()RepositoryBrowser<?>guessBrowser()booleanisAddGitTagAction()booleanisAllowSecondFetch()booleanisCreateAccountBasedOnEmail()booleanisDisableGitToolChooser()booleanisDoGenerateSubmoduleConfigurations()Deprecated.booleanisHideCredentials()booleanisUseExistingAccountWithSameEmail()static voidonLoaded()ObjectreadResolve()booleanrequiresWorkspaceForPolling()hudson.plugins.git.GitToolresolveGitTool(TaskListener listener)voidsetBrowser(GitRepositoryBrowser browser)voidsetBuildChooser(BuildChooser buildChooser)voidsetDoGenerateSubmoduleConfigurations(boolean ignoredValue)Data bound setter for doGenerateSubmoduleConfigurations that intentionally ignores the value passed by the caller.voidsetSubmoduleCfg(Collection<SubmoduleConfig> submoduleCfg)protected FilePathworkingDirectory(Job<?,?> context, FilePath workspace, EnvVars environment, TaskListener listener)Given the workspace, gets the working directory, which will be the workspace if no relative target dir is specified.-
Methods inherited from class hudson.plugins.git.GitSCMBackwardCompatibility
getAuthorOrCommitter, getClean, getDescriptor, getDisableSubmodules, getExcludedRegions, getExcludedRegionsNormalized, getExcludedUsers, getExcludedUsersNormalized, getGitConfigEmail, getGitConfigEmailToUse, getGitConfigName, getGitConfigNameToUse, getIncludedRegions, getIncludedRegionsNormalized, getLocalBranch, getPruneBranches, getRecursiveSubmodules, getReference, getRelativeTargetDir, getRemotePoll, getScmName, getSkipTag, getTrackingSubmodules, getUserMergeOptions, getUseShallowClone, getWipeOutWorkspace, isIgnoreNotifyCommit
-
Methods inherited from class hudson.scm.SCM
_calcRevisionsFromBuild, _for, _for, all, calcRevisionsFromBuild, checkout, compareRemoteRevisionWith, createEmptyChangeLog, createEmptyChangeLog, getApi, getEffectiveBrowser, getModuleRoot, getModuleRoot, getModuleRoots, getModuleRoots, getType, nullify, poll, pollChanges, postCheckout, postCheckout, processWorkspaceBeforeDeletion, processWorkspaceBeforeDeletion, supportsPolling
-
-
-
-
Field Detail
-
ALLOW_LOCAL_CHECKOUT
public static boolean ALLOW_LOCAL_CHECKOUT
-
gitTool
@CheckForNull public String gitTool
-
GIT_BRANCH
public static final String GIT_BRANCH
- See Also:
- Constant Field Values
-
GIT_LOCAL_BRANCH
public static final String GIT_LOCAL_BRANCH
- See Also:
- Constant Field Values
-
GIT_CHECKOUT_DIR
public static final String GIT_CHECKOUT_DIR
- See Also:
- Constant Field Values
-
GIT_COMMIT
public static final String GIT_COMMIT
- See Also:
- Constant Field Values
-
GIT_PREVIOUS_COMMIT
public static final String GIT_PREVIOUS_COMMIT
- See Also:
- Constant Field Values
-
GIT_PREVIOUS_SUCCESSFUL_COMMIT
public static final String GIT_PREVIOUS_SUCCESSFUL_COMMIT
- See Also:
- Constant Field Values
-
GIT_URL
public static final String GIT_URL
- See Also:
- Constant Field Values
-
GIT_REF
public static final Pattern GIT_REF
-
VERBOSE
public static boolean VERBOSE
Set to true to enable more logging to build'sTaskListener. Used by various classes in this package.
-
MAX_CHANGELOG
public static final int MAX_CHANGELOG
To avoid pointlessly large changelog, we'll limit the number of changes up to this.
-
-
Constructor Detail
-
GitSCM
public GitSCM(String repositoryUrl) throws hudson.plugins.git.GitException
A convenience constructor that sets everything to default.- Parameters:
repositoryUrl- git repository URL Repository URL to clone from.- Throws:
hudson.plugins.git.GitException
-
GitSCM
@Deprecated public GitSCM(List<UserRemoteConfig> userRemoteConfigs, List<BranchSpec> branches, Boolean doGenerateSubmoduleConfigurations, Collection<SubmoduleConfig> submoduleCfg, @CheckForNull GitRepositoryBrowser browser, @CheckForNull String gitTool, List<GitSCMExtension> extensions) throws hudson.plugins.git.GitException
Deprecated.- Throws:
hudson.plugins.git.GitException
-
GitSCM
@DataBoundConstructor public GitSCM(List<UserRemoteConfig> userRemoteConfigs, List<BranchSpec> branches, @CheckForNull GitRepositoryBrowser browser, @CheckForNull String gitTool, List<GitSCMExtension> extensions) throws hudson.plugins.git.GitException
- Throws:
hudson.plugins.git.GitException
-
-
Method Detail
-
getSubmoduleCfg
@Deprecated public Collection<SubmoduleConfig> getSubmoduleCfg()
Deprecated.
-
setSubmoduleCfg
@DataBoundSetter public void setSubmoduleCfg(Collection<SubmoduleConfig> submoduleCfg)
-
createRepoList
public static List<UserRemoteConfig> createRepoList(String url, String credentialsId)
-
getExtensions
public DescribableList<GitSCMExtension,GitSCMExtensionDescriptor> getExtensions()
All the configured extensions attached to thisGitSCM. Going forward this is primarily how we'll support esoteric use cases.- Since:
- 2.0
-
readResolve
public Object readResolve() throws IOException, hudson.plugins.git.GitException
- Throws:
IOExceptionhudson.plugins.git.GitException
-
getBrowser
public GitRepositoryBrowser getBrowser()
- Overrides:
getBrowserin classSCM
-
setBrowser
public void setBrowser(GitRepositoryBrowser browser)
-
guessBrowser
public RepositoryBrowser<?> guessBrowser()
- Overrides:
guessBrowserin classSCM
-
isCreateAccountBasedOnEmail
public boolean isCreateAccountBasedOnEmail()
-
isUseExistingAccountWithSameEmail
public boolean isUseExistingAccountWithSameEmail()
-
isHideCredentials
public boolean isHideCredentials()
-
isAllowSecondFetch
public boolean isAllowSecondFetch()
-
isDisableGitToolChooser
public boolean isDisableGitToolChooser()
-
isAddGitTagAction
public boolean isAddGitTagAction()
-
getBuildChooser
public BuildChooser getBuildChooser()
-
setBuildChooser
public void setBuildChooser(BuildChooser buildChooser) throws IOException
- Throws:
IOException
-
getParamLocalBranch
@Deprecated public String getParamLocalBranch(Run<?,?> build) throws IOException, InterruptedException
Deprecated.- Throws:
IOExceptionInterruptedException
-
getParamLocalBranch
public String getParamLocalBranch(Run<?,?> build, TaskListener listener) throws IOException, InterruptedException
Gets the parameter-expanded effective value in the context of the current build.- Parameters:
build- run whose local branch name is returnedlistener- build log- Returns:
- parameter-expanded local branch name in build.
- Throws:
IOException- on input or output errorInterruptedException- when interrupted
-
getParamExpandedRepos
@Deprecated public List<org.eclipse.jgit.transport.RemoteConfig> getParamExpandedRepos(Run<?,?> build) throws hudson.plugins.git.GitException, IOException, InterruptedException
Deprecated.- Throws:
hudson.plugins.git.GitExceptionIOExceptionInterruptedException
-
getParamExpandedRepos
public List<org.eclipse.jgit.transport.RemoteConfig> getParamExpandedRepos(Run<?,?> build, TaskListener listener) throws hudson.plugins.git.GitException, IOException, InterruptedException
Expand parameters inremoteRepositorieswith the parameter values provided in the given build and return them.- Parameters:
build- run whose local branch name is returnedlistener- build log- Returns:
- can be empty but never null.
- Throws:
IOException- on input or output errorInterruptedException- when interruptedhudson.plugins.git.GitException
-
getParamExpandedRepo
public org.eclipse.jgit.transport.RemoteConfig getParamExpandedRepo(EnvVars env, org.eclipse.jgit.transport.RemoteConfig remoteRepository) throws hudson.plugins.git.GitException
Expand Parameters in the supplied remote repository with the parameter values provided in the given environment variables- Parameters:
env- Environment variables with parameter valuesremoteRepository- Remote repository with parameters- Returns:
- remote repository with expanded parameters
- Throws:
hudson.plugins.git.GitException
-
getRepositoryByName
public org.eclipse.jgit.transport.RemoteConfig getRepositoryByName(String repoName)
-
getUserRemoteConfigs
@Exported public List<UserRemoteConfig> getUserRemoteConfigs()
-
getRepositories
public List<org.eclipse.jgit.transport.RemoteConfig> getRepositories()
-
deriveLocalBranchName
public String deriveLocalBranchName(String remoteBranchName)
Derives a local branch name from the remote branch name by removing the name of the remote from the remote branch name.Ex. origin/master becomes master
Cycles through the list of user remotes looking for a match allowing user to configure an alternate (not origin) name for the remote.
- Parameters:
remoteBranchName- branch name whose remote repository name will be removed- Returns:
- a local branch name derived by stripping the remote repository
name from the
remoteBranchNameparameter. If a matching remote is not found, the originalremoteBranchNamewill be returned.
-
getGitTool
@CheckForNull public String getGitTool()
-
getParameterString
@NonNull public static String getParameterString(@CheckForNull String original, @NonNull EnvVars env)
-
calcRevisionsFromBuild
public SCMRevisionState calcRevisionsFromBuild(Run<?,?> abstractBuild, FilePath workspace, Launcher launcher, TaskListener taskListener) throws IOException, InterruptedException
- Overrides:
calcRevisionsFromBuildin classSCM- Throws:
IOExceptionInterruptedException
-
requiresWorkspaceForPolling
public boolean requiresWorkspaceForPolling()
- Overrides:
requiresWorkspaceForPollingin classSCM
-
compareRemoteRevisionWith
public PollingResult compareRemoteRevisionWith(Job<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException
- Overrides:
compareRemoteRevisionWithin classSCM- Throws:
IOExceptionInterruptedException
-
createClient
@NonNull public org.jenkinsci.plugins.gitclient.GitClient createClient(TaskListener listener, EnvVars environment, @NonNull Run<?,?> build, FilePath workspace) throws hudson.plugins.git.GitException, IOException, InterruptedException
AllowsBuilders andPublishers to access a configuredGitClientobject to perform additional git operations.- Parameters:
listener- build logenvironment- environment variables to be usedbuild- run context for the returned GitClientworkspace- client workspace- Returns:
- git client for additional git operations
- Throws:
IOException- on input or output errorInterruptedException- when interruptedhudson.plugins.git.GitException
-
createClient
@NonNull public org.jenkinsci.plugins.gitclient.GitClient createClient(TaskListener listener, EnvVars environment, @NonNull Run<?,?> build, FilePath workspace, org.jenkinsci.plugins.gitclient.UnsupportedCommand postBuildUnsupportedCommand) throws hudson.plugins.git.GitException, IOException, InterruptedException
AllowsPublisherand other post build actions to access a configuredGitClient. The post build action can use thepostBuildUnsupportedCommandargument to control the selection of a git tool byGitToolChooser.- Parameters:
listener- build logenvironment- environment variables to be usedbuild- run context for the returned GitClientworkspace- client workspacepostBuildUnsupportedCommand- passed by caller to control choice of git tool by GitTooChooser- Returns:
- git client for additional git operations
- Throws:
IOException- on input or output errorInterruptedException- when interruptedhudson.plugins.git.GitException
-
resolveGitTool
@CheckForNull public hudson.plugins.git.GitTool resolveGitTool(TaskListener listener)
-
getGitExe
public String getGitExe(Node builtOn, TaskListener listener)
-
getGitExe
public String getGitExe(Node builtOn, EnvVars env, TaskListener listener)
Exposing so that we can get this from GitPublisher.- Parameters:
builtOn- node where build was performedenv- environment variables used in the buildlistener- build log- Returns:
- git exe for builtOn node, often "Default" or "jgit"
-
getGitTool
public hudson.plugins.git.GitTool getGitTool(Node builtOn, EnvVars env, TaskListener listener)
-
checkout
public void checkout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException
- Overrides:
checkoutin classSCM- Throws:
IOExceptionInterruptedException
-
buildEnvVars
@Deprecated public void buildEnvVars(AbstractBuild<?,?> build, Map<String,String> env)
Deprecated.- Overrides:
buildEnvVarsin classSCM
-
buildEnvironment
public void buildEnvironment(Run<?,?> build, Map<String,String> env)
- Overrides:
buildEnvironmentin classSCM
-
createChangeLogParser
public ChangeLogParser createChangeLogParser()
- Specified by:
createChangeLogParserin classSCM
-
isDoGenerateSubmoduleConfigurations
@Deprecated public boolean isDoGenerateSubmoduleConfigurations()
Deprecated.
-
getBranches
@Exported public List<BranchSpec> getBranches()
-
getMergeOptions
@Exported @Deprecated public PreBuildMergeOptions getMergeOptions() throws Descriptor.FormException
Deprecated.UsePreBuildMerge.- Returns:
- pre-build merge options
- Throws:
Descriptor.FormException- on form error
-
getBuildData
@Deprecated public BuildData getBuildData(Run build, boolean clone)
Deprecated.- Parameters:
build- run whose build data is returnedclone- true if returned build data should be copied rather than referenced- Returns:
- build data for build run
-
copyBuildData
public BuildData copyBuildData(Run build)
LikegetBuildData(Run), but copy the data into a new object, which is used as the first step for updating the data for the next build.- Parameters:
build- run whose BuildData is returned- Returns:
- copy of build data for build
-
getBuildData
@CheckForNull public BuildData getBuildData(Run build)
Find the build log (BuildData) recorded with the last build that completed. BuildData may not be recorded if an exception occurs in the plugin logic.- Parameters:
build- run whose build data is returned- Returns:
- the last recorded build data
-
workingDirectory
protected FilePath workingDirectory(Job<?,?> context, FilePath workspace, EnvVars environment, TaskListener listener) throws hudson.plugins.git.GitException, IOException, InterruptedException
Given the workspace, gets the working directory, which will be the workspace if no relative target dir is specified. Otherwise, it'll be "workspace/relativeTargetDir".- Parameters:
context- job context for working directoryworkspace- initial FilePath of job workspaceenvironment- environment variables used in job contextlistener- build log- Returns:
- working directory or null if workspace is null
- Throws:
IOException- on input or output errorInterruptedException- when interruptedhudson.plugins.git.GitException
-
setDoGenerateSubmoduleConfigurations
@DataBoundSetter public void setDoGenerateSubmoduleConfigurations(boolean ignoredValue)
Data bound setter for doGenerateSubmoduleConfigurations that intentionally ignores the value passed by the caller. Submodule configuration generation was untested and unlikely to work prior to git plugin 4.6.0. It was removed from git plugin 4.6.0 to improve the experience for Pipeline Syntax users.- Parameters:
ignoredValue- ignored because submodule configuration generation is no longer supported
-
getDoGenerateSubmoduleConfigurations
@Deprecated public boolean getDoGenerateSubmoduleConfigurations()
Deprecated.Returns false, the constant value of doGenerateSubmoduleConfigurations.- Returns:
- false, the constant value of doGenerateSubmoduleConfigurations.
-
onLoaded
@Initializer(after=PLUGINS_STARTED) public static void onLoaded()
-
configureXtream
@Initializer(before=JOB_LOADED) public static void configureXtream()
-
-