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
Git SCM.
- Author:
- Nigel Magnay, Andrew Bayer, Nicolas Deloof, Kohsuke Kawaguchi ... and many others
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final Pattern
static final String
static final int
To avoid pointlessly large changelog, we'll limit the number of changes up to this.static boolean
Set to true to enable more logging to build'sTaskListener
.Fields inherited from class hudson.scm.SCM
PERMISSIONS, TAG
-
Constructor Summary
ConstructorDescriptionA 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
Modifier and TypeMethodDescriptionvoid
buildEnvironment
(Run<?, ?> build, Map<String, String> env) void
buildEnvVars
(AbstractBuild<?, ?> build, Map<String, String> env) Deprecated.calcRevisionsFromBuild
(Run<?, ?> abstractBuild, FilePath workspace, Launcher launcher, TaskListener taskListener) void
checkout
(Run<?, ?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) compareRemoteRevisionWith
(Job<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) static void
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.org.jenkinsci.plugins.gitclient.GitClient
createClient
(TaskListener listener, EnvVars environment, Run<?, ?> build, FilePath workspace) org.jenkinsci.plugins.gitclient.GitClient
createClient
(TaskListener listener, EnvVars environment, Run<?, ?> build, FilePath workspace, org.jenkinsci.plugins.gitclient.UnsupportedCommand postBuildUnsupportedCommand) AllowsPublisher
and other post build actions to access a configuredGitClient
.static List<UserRemoteConfig>
createRepoList
(String url, String credentialsId) 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.getBuildData
(Run build) Find the build log (BuildData) recorded with the last build that completed.getBuildData
(Run build, boolean clone) Deprecated.boolean
Deprecated.All the configured extensions attached to thisGitSCM
.getGitExe
(Node builtOn, EnvVars env, TaskListener listener) Exposing so that we can get this from GitPublisher.getGitExe
(Node builtOn, TaskListener listener) hudson.plugins.git.GitTool
getGitTool
(Node builtOn, EnvVars env, TaskListener listener) getKey()
Deprecated.static String
getParameterString
(String original, EnvVars env) org.eclipse.jgit.transport.RemoteConfig
getParamExpandedRepo
(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 inremoteRepositories
with the parameter values provided in the given build and return them.getParamLocalBranch
(Run<?, ?> build) Deprecated.getParamLocalBranch
(Run<?, ?> build, TaskListener listener) Gets the parameter-expanded effective value in the context of the current build.List<org.eclipse.jgit.transport.RemoteConfig>
org.eclipse.jgit.transport.RemoteConfig
getRepositoryByName
(String repoName) Deprecated.boolean
boolean
boolean
boolean
boolean
Deprecated.boolean
boolean
static void
onLoaded()
boolean
hudson.plugins.git.GitTool
resolveGitTool
(TaskListener listener) void
setBrowser
(GitRepositoryBrowser browser) void
setBuildChooser
(BuildChooser buildChooser) void
setDoGenerateSubmoduleConfigurations
(boolean ignoredValue) Data bound setter for doGenerateSubmoduleConfigurations that intentionally ignores the value passed by the caller.void
setSubmoduleCfg
(Collection<SubmoduleConfig> submoduleCfg) protected FilePath
workingDirectory
(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 Details
-
ALLOW_LOCAL_CHECKOUT
public static boolean ALLOW_LOCAL_CHECKOUT -
gitTool
-
GIT_BRANCH
- See Also:
-
GIT_LOCAL_BRANCH
- See Also:
-
GIT_CHECKOUT_DIR
- See Also:
-
GIT_COMMIT
- See Also:
-
GIT_PREVIOUS_COMMIT
- See Also:
-
GIT_PREVIOUS_SUCCESSFUL_COMMIT
- See Also:
-
GIT_URL
- See Also:
-
GIT_REF
-
VERBOSE
public static boolean VERBOSESet to true to enable more logging to build'sTaskListener
. Used by various classes in this package. -
MAX_CHANGELOG
public static final int MAX_CHANGELOGTo avoid pointlessly large changelog, we'll limit the number of changes up to this.
-
-
Constructor Details
-
GitSCM
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 Details
-
getSubmoduleCfg
Deprecated. -
setSubmoduleCfg
-
createRepoList
-
getExtensions
All the configured extensions attached to thisGitSCM
. Going forward this is primarily how we'll support esoteric use cases.- Since:
- 2.0
-
readResolve
- Throws:
IOException
hudson.plugins.git.GitException
-
getBrowser
- Overrides:
getBrowser
in classSCM
-
setBrowser
-
guessBrowser
- Overrides:
guessBrowser
in 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
-
setBuildChooser
- Throws:
IOException
-
getParamLocalBranch
@Deprecated public String getParamLocalBranch(Run<?, ?> build) throws IOException, InterruptedExceptionDeprecated.- Throws:
IOException
InterruptedException
-
getParamLocalBranch
public String getParamLocalBranch(Run<?, ?> build, TaskListener listener) throws IOException, InterruptedExceptionGets 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, InterruptedExceptionDeprecated.- Throws:
hudson.plugins.git.GitException
IOException
InterruptedException
-
getParamExpandedRepos
public List<org.eclipse.jgit.transport.RemoteConfig> getParamExpandedRepos(Run<?, ?> build, TaskListener listener) throws hudson.plugins.git.GitException, IOException, InterruptedExceptionExpand parameters inremoteRepositories
with 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
-
getUserRemoteConfigs
-
getRepositories
-
deriveLocalBranchName
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
remoteBranchName
parameter. If a matching remote is not found, the originalremoteBranchName
will be returned.
-
getGitTool
-
getParameterString
-
calcRevisionsFromBuild
public SCMRevisionState calcRevisionsFromBuild(Run<?, ?> abstractBuild, FilePath workspace, Launcher launcher, TaskListener taskListener) throws IOException, InterruptedException- Overrides:
calcRevisionsFromBuild
in classSCM
- Throws:
IOException
InterruptedException
-
requiresWorkspaceForPolling
public boolean requiresWorkspaceForPolling()- Overrides:
requiresWorkspaceForPolling
in classSCM
-
compareRemoteRevisionWith
public PollingResult compareRemoteRevisionWith(Job<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline) throws IOException, InterruptedException- Overrides:
compareRemoteRevisionWith
in classSCM
- Throws:
IOException
InterruptedException
-
createClient
@NonNull public org.jenkinsci.plugins.gitclient.GitClient createClient(TaskListener listener, EnvVars environment, @NonNull Run<?, ?> build, FilePath workspace) throws hudson.plugins.git.GitException, IOException, InterruptedExceptionAllowsBuilder
s andPublisher
s to access a configuredGitClient
object 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, InterruptedExceptionAllowsPublisher
and other post build actions to access a configuredGitClient
. The post build action can use thepostBuildUnsupportedCommand
argument 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
-
getGitExe
-
getGitExe
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
-
checkout
public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException- Overrides:
checkout
in classSCM
- Throws:
IOException
InterruptedException
-
buildEnvVars
Deprecated.- Overrides:
buildEnvVars
in classSCM
-
buildEnvironment
- Overrides:
buildEnvironment
in classSCM
-
createChangeLogParser
- Specified by:
createChangeLogParser
in classSCM
-
isDoGenerateSubmoduleConfigurations
Deprecated. -
getBranches
-
getKey
-
getMergeOptions
Deprecated.UsePreBuildMerge
.- Returns:
- pre-build merge options
- Throws:
Descriptor.FormException
- on form error
-
getBuildData
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
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
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, InterruptedExceptionGiven 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.Returns false, the constant value of doGenerateSubmoduleConfigurations.- Returns:
- false, the constant value of doGenerateSubmoduleConfigurations.
-
onLoaded
-
configureXtream
-
PreBuildMerge
.