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 class
GitSCM.DescriptorImpl
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
ALLOW_LOCAL_CHECKOUT
static String
GIT_BRANCH
static String
GIT_CHECKOUT_DIR
static String
GIT_COMMIT
static String
GIT_LOCAL_BRANCH
static String
GIT_PREVIOUS_COMMIT
static String
GIT_PREVIOUS_SUCCESSFUL_COMMIT
static Pattern
GIT_REF
static String
GIT_URL
String
gitTool
static int
MAX_CHANGELOG
To avoid pointlessly large changelog, we'll limit the number of changes up to this.static boolean
VERBOSE
Set 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 void
buildEnvironment(Run<?,?> build, Map<String,String> env)
void
buildEnvVars(AbstractBuild<?,?> build, Map<String,String> env)
Deprecated.SCMRevisionState
calcRevisionsFromBuild(Run<?,?> abstractBuild, FilePath workspace, Launcher launcher, TaskListener taskListener)
void
checkout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline)
PollingResult
compareRemoteRevisionWith(Job<?,?> project, Launcher launcher, FilePath workspace, TaskListener listener, SCMRevisionState baseline)
static void
configureXtream()
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.ChangeLogParser
createChangeLogParser()
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)
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.List<BranchSpec>
getBranches()
GitRepositoryBrowser
getBrowser()
BuildChooser
getBuildChooser()
BuildData
getBuildData(Run build)
Find the build log (BuildData) recorded with the last build that completed.BuildData
getBuildData(Run build, boolean clone)
Deprecated.boolean
getDoGenerateSubmoduleConfigurations()
Deprecated.DescribableList<GitSCMExtension,GitSCMExtensionDescriptor>
getExtensions()
All the configured extensions attached to thisGitSCM
.String
getGitExe(Node builtOn, EnvVars env, TaskListener listener)
Exposing so that we can get this from GitPublisher.String
getGitExe(Node builtOn, TaskListener listener)
String
getGitTool()
hudson.plugins.git.GitTool
getGitTool(Node builtOn, EnvVars env, TaskListener listener)
String
getKey()
PreBuildMergeOptions
getMergeOptions()
Deprecated.UsePreBuildMerge
.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.String
getParamLocalBranch(Run<?,?> build)
Deprecated.String
getParamLocalBranch(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.RemoteConfig
getRepositoryByName(String repoName)
Collection<SubmoduleConfig>
getSubmoduleCfg()
Deprecated.List<UserRemoteConfig>
getUserRemoteConfigs()
RepositoryBrowser<?>
guessBrowser()
boolean
isAddGitTagAction()
boolean
isAllowSecondFetch()
boolean
isCreateAccountBasedOnEmail()
boolean
isDisableGitToolChooser()
boolean
isDoGenerateSubmoduleConfigurations()
Deprecated.boolean
isHideCredentials()
boolean
isUseExistingAccountWithSameEmail()
static void
onLoaded()
Object
readResolve()
boolean
requiresWorkspaceForPolling()
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 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:
IOException
hudson.plugins.git.GitException
-
getBrowser
public GitRepositoryBrowser getBrowser()
- Overrides:
getBrowser
in classSCM
-
setBrowser
public void setBrowser(GitRepositoryBrowser browser)
-
guessBrowser
public RepositoryBrowser<?> 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
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:
IOException
InterruptedException
-
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.GitException
IOException
InterruptedException
-
getParamExpandedRepos
public List<org.eclipse.jgit.transport.RemoteConfig> getParamExpandedRepos(Run<?,?> build, TaskListener listener) throws hudson.plugins.git.GitException, IOException, InterruptedException
Expand 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
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
remoteBranchName
parameter. If a matching remote is not found, the originalremoteBranchName
will 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:
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, InterruptedException
AllowsBuilder
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, InterruptedException
AllowsPublisher
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
@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:
checkout
in classSCM
- Throws:
IOException
InterruptedException
-
buildEnvVars
@Deprecated public void buildEnvVars(AbstractBuild<?,?> build, Map<String,String> env)
Deprecated.- Overrides:
buildEnvVars
in classSCM
-
buildEnvironment
public void buildEnvironment(Run<?,?> build, Map<String,String> env)
- Overrides:
buildEnvironment
in classSCM
-
createChangeLogParser
public ChangeLogParser createChangeLogParser()
- Specified by:
createChangeLogParser
in 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()
-
-