Package jenkins.plugins.git
Class GitSCMBuilder<B extends GitSCMBuilder<B>>
java.lang.Object
jenkins.scm.api.trait.SCMBuilder<B,GitSCM>
jenkins.plugins.git.GitSCMBuilder<B>
- Type Parameters:
B
- the concrete type ofGitSCMBuilder
so that subclasses can chain correctly in theirSCMBuilder.withHead(SCMHead)
etc methods.
public class GitSCMBuilder<B extends GitSCMBuilder<B>>
extends jenkins.scm.api.trait.SCMBuilder<B,GitSCM>
The
SCMBuilder
base class for AbstractGitSCMSource
.- Since:
- 3.4.0
-
Constructor Summary
ConstructorDescriptionGitSCMBuilder
(jenkins.scm.api.SCMHead head, jenkins.scm.api.SCMRevision revision, String remote, String credentialsId) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal String
additionalRemote
(String remoteName) Gets the remote URL of the git repository for the specified remote name.Gets the (possibly empty) additional remote names.additionalRemoteRefSpecs
(String remoteName) Gets the ref specs to use for the git repository of the specified remote name.final List<org.eclipse.jgit.transport.RefSpec>
Converts the ref spec templates intoRefSpec
instances.final List<UserRemoteConfig>
Converts theasRefSpecs()
intoUserRemoteConfig
instances.final GitRepositoryBrowser
browser()
Returns theGitRepositoryBrowser
ornull
to use the "auto" browser.build()
final String
Returns theIdCredentials.getId()
of theCredentials
to use when connecting to theremote
ornull
to let the git client choose between providing its own credentials or connecting anonymously.final List<GitSCMExtension>
Returns theGitSCMExtension
instances to apply to theGitSCM
.final String
gitTool()
Returns the name of theGitTool
to use ornull
to use the default.refSpecs()
Returns the list of ref specs to use.final String
remote()
Returns the remote URL of the git repository.final String
Returns the name to give the remote.final B
withAdditionalRemote
(String remoteName, String remote, String... refSpecs) Configures an additional remote.final B
withAdditionalRemote
(String remoteName, String remote, List<String> refSpecs) Configures an additional remote.final B
withBrowser
(GitRepositoryBrowser browser) Configures theGitRepositoryBrowser
to use.final B
withCredentials
(String credentialsId) final B
withExtension
(GitSCMExtension extension) Adds (or redefines) the suppliedGitSCMExtension
.final B
withExtensions
(GitSCMExtension... extensions) Adds (or redefines) the suppliedGitSCMExtension
s.final B
withExtensions
(List<GitSCMExtension> extensions) Adds (or redefines) the suppliedGitSCMExtension
s.final B
withGitTool
(String gitTool) Configures theToolInstallation.getName()
to use.final B
Clears the specified ref specs.final B
withRefSpec
(String refSpec) Adds the specified ref spec.final B
withRefSpecs
(List<String> refSpecs) Adds the specified ref specs.final B
withRemote
(String remote) Replaces the URL of the git repository.final B
withRemoteName
(String remoteName) Configures the remote name to use for the git repository.Methods inherited from class jenkins.scm.api.trait.SCMBuilder
head, revision, scmClass, withHead, withRevision, withTrait, withTraits, withTraits
-
Constructor Details
-
GitSCMBuilder
public GitSCMBuilder(@NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMRevision revision, @NonNull String remote, @CheckForNull String credentialsId) Constructor.- Parameters:
head
- TheSCMHead
to produce theSCM
for.revision
- TheSCMRevision
to produce theSCM
for ornull
to produce theSCM
for the head revision.remote
- The remote URL of the git server.credentialsId
- TheIdCredentials.getId()
of theCredentials
to use when connecting to theremote
ornull
to let the git client choose between providing its own credentials or connecting anonymously.
-
-
Method Details
-
browser
Returns theGitRepositoryBrowser
ornull
to use the "auto" browser.- Returns:
- The
GitRepositoryBrowser
ornull
to use the "auto" browser.
-
credentialsId
Returns theIdCredentials.getId()
of theCredentials
to use when connecting to theremote
ornull
to let the git client choose between providing its own credentials or connecting anonymously.- Returns:
- the
IdCredentials.getId()
of theCredentials
to use when connecting to theremote
ornull
to let the git client choose between providing its own credentials or connecting anonymously.
-
extensions
Returns theGitSCMExtension
instances to apply to theGitSCM
.- Returns:
- the
GitSCMExtension
instances to apply to theGitSCM
.
-
gitTool
Returns the name of theGitTool
to use ornull
to use the default.- Returns:
- the name of the
GitTool
to use ornull
to use the default.
-
refSpecs
Returns the list of ref specs to use.- Returns:
- the list of ref specs to use.
-
remote
Returns the remote URL of the git repository.- Returns:
- the remote URL of the git repository.
-
remoteName
Returns the name to give the remote.- Returns:
- the name to give the remote.
-
additionalRemoteNames
Gets the (possibly empty) additional remote names.- Returns:
- the (possibly empty) additional remote names.
-
additionalRemote
Gets the remote URL of the git repository for the specified remote name.- Parameters:
remoteName
- the additional remote name.- Returns:
- the remote URL of the named additional remote or
null
if the supplied name is not inadditionalRemoteNames()
-
additionalRemoteRefSpecs
Gets the ref specs to use for the git repository of the specified remote name.- Parameters:
remoteName
- the additional remote name.- Returns:
- the ref specs for the named additional remote or
null
if the supplied name is not inadditionalRemoteNames()
-
withBrowser
Configures theGitRepositoryBrowser
to use.- Parameters:
browser
- theGitRepositoryBrowser
ornull
to use the default "auto" browser.- Returns:
this
for method chaining.
-
withCredentials
- Parameters:
credentialsId
- theIdCredentials.getId()
of theCredentials
to use when connecting to theremote()
ornull
to let the git client choose between providing its own credentials or connecting anonymously.- Returns:
this
for method chaining.
-
withExtension
Adds (or redefines) the suppliedGitSCMExtension
.- Parameters:
extension
- theGitSCMExtension
(null
values are safely ignored).- Returns:
this
for method chaining.
-
withExtensions
Adds (or redefines) the suppliedGitSCMExtension
s.- Parameters:
extensions
- theGitSCMExtension
s.- Returns:
this
for method chaining.
-
withExtensions
Adds (or redefines) the suppliedGitSCMExtension
s.- Parameters:
extensions
- theGitSCMExtension
s.- Returns:
this
for method chaining.
-
withGitTool
Configures theToolInstallation.getName()
to use.- Parameters:
gitTool
- theToolInstallation.getName()
ornull
to use the system default.- Returns:
this
for method chaining.
-
withRefSpec
Adds the specified ref spec. If no ref specs were previously defined then the supplied ref spec will replaceAbstractGitSCMSource.REF_SPEC_DEFAULT
. The ref spec is expected to be processed for substitution ofAbstractGitSCMSource.REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR
byremote()
before use.- Parameters:
refSpec
- the ref spec template to add.- Returns:
this
for method chaining.- See Also:
-
withRefSpecs
Adds the specified ref specs. If no ref specs were previously defined then the supplied ref specs will replaceAbstractGitSCMSource.REF_SPEC_DEFAULT
. The ref spec is expected to be processed for substitution ofAbstractGitSCMSource.REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR
byremote()
before use.- Parameters:
refSpecs
- the ref spec templates to add.- Returns:
this
for method chaining.- See Also:
-
withoutRefSpecs
Clears the specified ref specs. If no ref specs are subsequently defined thenAbstractGitSCMSource.REF_SPEC_DEFAULT
will be used as the ref spec template.- Returns:
this
for method chaining.
-
withRemote
Replaces the URL of the git repository.- Parameters:
remote
- the new URL to use for the git repository.- Returns:
this
for method chaining.
-
withRemoteName
Configures the remote name to use for the git repository.- Parameters:
remoteName
- the remote name to use for the git repository (null
or the empty string are equivalent to passingAbstractGitSCMSource.DEFAULT_REMOTE_NAME
).- Returns:
this
for method chaining.
-
withAdditionalRemote
@NonNull public final B withAdditionalRemote(@NonNull String remoteName, @NonNull String remote, String... refSpecs) Configures an additional remote. It is the responsibility of the caller to ensure that there are no conflicts with the eventualremote()
name.- Parameters:
remoteName
- the name of the additional remote.remote
- the url of the additional remote.refSpecs
- the ref specs of the additional remote, if empty will default toAbstractGitSCMSource.REF_SPEC_DEFAULT
- Returns:
this
for method chaining.
-
withAdditionalRemote
@NonNull public final B withAdditionalRemote(@NonNull String remoteName, @NonNull String remote, List<String> refSpecs) Configures an additional remote. It is the responsibility of the caller to ensure that there are no conflicts with the eventualremote()
name.- Parameters:
remoteName
- the name of the additional remote.remote
- the url of the additional remote.refSpecs
- the ref specs of the additional remote, if empty will default toAbstractGitSCMSource.REF_SPEC_DEFAULT
- Returns:
this
for method chaining.
-
asRefSpecs
Converts the ref spec templates intoRefSpec
instances.- Returns:
- the list of
RefSpec
instances.
-
asRemoteConfigs
Converts theasRefSpecs()
intoUserRemoteConfig
instances.- Returns:
- the list of
UserRemoteConfig
instances.
-
build
- Specified by:
build
in classjenkins.scm.api.trait.SCMBuilder<B extends GitSCMBuilder<B>,
GitSCM>
-