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 ofGitSCMBuilderso 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>
TheSCMBuilderbase class forAbstractGitSCMSource.- Since:
- 3.4.0
-
-
Constructor Summary
Constructors Constructor Description GitSCMBuilder(jenkins.scm.api.SCMHead head, jenkins.scm.api.SCMRevision revision, String remote, String credentialsId)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringadditionalRemote(String remoteName)Gets the remote URL of the git repository for the specified remote name.Set<String>additionalRemoteNames()Gets the (possibly empty) additional remote names.List<String>additionalRemoteRefSpecs(String remoteName)Gets the ref specs to use for the git repository of the specified remote name.List<org.eclipse.jgit.transport.RefSpec>asRefSpecs()Converts the ref spec templates intoRefSpecinstances.List<UserRemoteConfig>asRemoteConfigs()Converts theasRefSpecs()intoUserRemoteConfiginstances.GitRepositoryBrowserbrowser()Returns theGitRepositoryBrowserornullto use the "auto" browser.GitSCMbuild()StringcredentialsId()Returns theIdCredentials.getId()of theCredentialsto use when connecting to theremoteornullto let the git client choose between providing its own credentials or connecting anonymously.List<GitSCMExtension>extensions()Returns theGitSCMExtensioninstances to apply to theGitSCM.StringgitTool()Returns the name of theGitToolto use ornullto use the default.List<String>refSpecs()Returns the list of ref specs to use.Stringremote()Returns the remote URL of the git repository.StringremoteName()Returns the name to give the remote.BwithAdditionalRemote(String remoteName, String remote, String... refSpecs)Configures an additional remote.BwithAdditionalRemote(String remoteName, String remote, List<String> refSpecs)Configures an additional remote.BwithBrowser(GitRepositoryBrowser browser)Configures theGitRepositoryBrowserto use.BwithCredentials(String credentialsId)BwithExtension(GitSCMExtension extension)Adds (or redefines) the suppliedGitSCMExtension.BwithExtensions(GitSCMExtension... extensions)Adds (or redefines) the suppliedGitSCMExtensions.BwithExtensions(List<GitSCMExtension> extensions)Adds (or redefines) the suppliedGitSCMExtensions.BwithGitTool(String gitTool)Configures theToolInstallation.getName()to use.BwithoutRefSpecs()Clears the specified ref specs.BwithRefSpec(String refSpec)Adds the specified ref spec.BwithRefSpecs(List<String> refSpecs)Adds the specified ref specs.BwithRemote(String remote)Replaces the URL of the git repository.BwithRemoteName(String remoteName)Configures the remote name to use for the git repository.
-
-
-
Constructor Detail
-
GitSCMBuilder
public GitSCMBuilder(@NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMRevision revision, @NonNull String remote, @CheckForNull String credentialsId)Constructor.- Parameters:
head- TheSCMHeadto produce theSCMfor.revision- TheSCMRevisionto produce theSCMfor ornullto produce theSCMfor the head revision.remote- The remote URL of the git server.credentialsId- TheIdCredentials.getId()of theCredentialsto use when connecting to theremoteornullto let the git client choose between providing its own credentials or connecting anonymously.
-
-
Method Detail
-
browser
@CheckForNull public final GitRepositoryBrowser browser()
Returns theGitRepositoryBrowserornullto use the "auto" browser.- Returns:
- The
GitRepositoryBrowserornullto use the "auto" browser.
-
credentialsId
@CheckForNull public final String credentialsId()
Returns theIdCredentials.getId()of theCredentialsto use when connecting to theremoteornullto let the git client choose between providing its own credentials or connecting anonymously.- Returns:
- the
IdCredentials.getId()of theCredentialsto use when connecting to theremoteornullto let the git client choose between providing its own credentials or connecting anonymously.
-
extensions
@NonNull public final List<GitSCMExtension> extensions()
Returns theGitSCMExtensioninstances to apply to theGitSCM.- Returns:
- the
GitSCMExtensioninstances to apply to theGitSCM.
-
gitTool
@CheckForNull public final String gitTool()
Returns the name of theGitToolto use ornullto use the default.- Returns:
- the name of the
GitToolto use ornullto use the default.
-
refSpecs
@NonNull public final List<String> refSpecs()
Returns the list of ref specs to use.- Returns:
- the list of ref specs to use.
-
remote
@NonNull public final String remote()
Returns the remote URL of the git repository.- Returns:
- the remote URL of the git repository.
-
remoteName
@NonNull public final String remoteName()
Returns the name to give the remote.- Returns:
- the name to give the remote.
-
additionalRemoteNames
@NonNull public final Set<String> additionalRemoteNames()
Gets the (possibly empty) additional remote names.- Returns:
- the (possibly empty) additional remote names.
-
additionalRemote
@CheckForNull public final String additionalRemote(String remoteName)
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
nullif the supplied name is not inadditionalRemoteNames()
-
additionalRemoteRefSpecs
@CheckForNull public final List<String> additionalRemoteRefSpecs(String remoteName)
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
nullif the supplied name is not inadditionalRemoteNames()
-
withBrowser
@NonNull public final B withBrowser(@CheckForNull GitRepositoryBrowser browser)
Configures theGitRepositoryBrowserto use.- Parameters:
browser- theGitRepositoryBrowserornullto use the default "auto" browser.- Returns:
thisfor method chaining.
-
withCredentials
@NonNull public final B withCredentials(@CheckForNull String credentialsId)
- Parameters:
credentialsId- theIdCredentials.getId()of theCredentialsto use when connecting to theremote()ornullto let the git client choose between providing its own credentials or connecting anonymously.- Returns:
thisfor method chaining.
-
withExtension
@NonNull public final B withExtension(@CheckForNull GitSCMExtension extension)
Adds (or redefines) the suppliedGitSCMExtension.- Parameters:
extension- theGitSCMExtension(nullvalues are safely ignored).- Returns:
thisfor method chaining.
-
withExtensions
@NonNull public final B withExtensions(GitSCMExtension... extensions)
Adds (or redefines) the suppliedGitSCMExtensions.- Parameters:
extensions- theGitSCMExtensions.- Returns:
thisfor method chaining.
-
withExtensions
@NonNull public final B withExtensions(@NonNull List<GitSCMExtension> extensions)
Adds (or redefines) the suppliedGitSCMExtensions.- Parameters:
extensions- theGitSCMExtensions.- Returns:
thisfor method chaining.
-
withGitTool
@NonNull public final B withGitTool(@CheckForNull String gitTool)
Configures theToolInstallation.getName()to use.- Parameters:
gitTool- theToolInstallation.getName()ornullto use the system default.- Returns:
thisfor method chaining.
-
withRefSpec
@NonNull public final B withRefSpec(@NonNull String refSpec)
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_STRbyremote()before use.- Parameters:
refSpec- the ref spec template to add.- Returns:
thisfor method chaining.- See Also:
withoutRefSpecs()
-
withRefSpecs
@NonNull public final B withRefSpecs(@NonNull List<String> refSpecs)
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_STRbyremote()before use.- Parameters:
refSpecs- the ref spec templates to add.- Returns:
thisfor method chaining.- See Also:
withoutRefSpecs()
-
withoutRefSpecs
@NonNull public final B withoutRefSpecs()
Clears the specified ref specs. If no ref specs are subsequently defined thenAbstractGitSCMSource.REF_SPEC_DEFAULTwill be used as the ref spec template.- Returns:
thisfor method chaining.
-
withRemote
@NonNull public final B withRemote(@NonNull String remote)
Replaces the URL of the git repository.- Parameters:
remote- the new URL to use for the git repository.- Returns:
thisfor method chaining.
-
withRemoteName
@NonNull public final B withRemoteName(@CheckForNull String remoteName)
Configures the remote name to use for the git repository.- Parameters:
remoteName- the remote name to use for the git repository (nullor the empty string are equivalent to passingAbstractGitSCMSource.DEFAULT_REMOTE_NAME).- Returns:
thisfor 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:
thisfor 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:
thisfor method chaining.
-
asRefSpecs
@NonNull public final List<org.eclipse.jgit.transport.RefSpec> asRefSpecs()
Converts the ref spec templates intoRefSpecinstances.- Returns:
- the list of
RefSpecinstances.
-
asRemoteConfigs
@NonNull public final List<UserRemoteConfig> asRemoteConfigs()
Converts theasRefSpecs()intoUserRemoteConfiginstances.- Returns:
- the list of
UserRemoteConfiginstances.
-
build
@NonNull public GitSCM build()
- Specified by:
buildin classjenkins.scm.api.trait.SCMBuilder<B extends GitSCMBuilder<B>,GitSCM>
-
-