Class GitSCMBuilder<B extends GitSCMBuilder<B>>

  • Type Parameters:
    B - the concrete type of GitSCMBuilder so that subclasses can chain correctly in their SCMBuilder.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 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 - The SCMHead to produce the SCM for.
        revision - The SCMRevision to produce the SCM for or null to produce the SCM for the head revision.
        remote - The remote URL of the git server.
        credentialsId - The IdCredentials.getId() of the Credentials to use when connecting to the remote or null to let the git client choose between providing its own credentials or connecting anonymously.
    • Method Detail

      • credentialsId

        @CheckForNull
        public final String credentialsId()
        Returns the IdCredentials.getId() of the Credentials to use when connecting to the remote or null to let the git client choose between providing its own credentials or connecting anonymously.
        Returns:
        the IdCredentials.getId() of the Credentials to use when connecting to the remote or null to let the git client choose between providing its own credentials or connecting anonymously.
      • gitTool

        @CheckForNull
        public final String gitTool()
        Returns the name of the GitTool to use or null to use the default.
        Returns:
        the name of the GitTool to use or null to 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 null if the supplied name is not in additionalRemoteNames()
      • 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 null if the supplied name is not in additionalRemoteNames()
      • withCredentials

        @NonNull
        public final B withCredentials​(@CheckForNull
                                       String credentialsId)
        Configures the IdCredentials.getId() of the Credentials to use when connecting to the remote()
        Parameters:
        credentialsId - the IdCredentials.getId() of the Credentials to use when connecting to the remote() or null to let the git client choose between providing its own credentials or connecting anonymously.
        Returns:
        this for method chaining.
      • withExtension

        @NonNull
        public final B withExtension​(@CheckForNull
                                     GitSCMExtension extension)
        Adds (or redefines) the supplied GitSCMExtension.
        Parameters:
        extension - the GitSCMExtension (null values are safely ignored).
        Returns:
        this for method chaining.
      • withoutRefSpecs

        @NonNull
        public final B withoutRefSpecs()
        Clears the specified ref specs. If no ref specs are subsequently defined then AbstractGitSCMSource.REF_SPEC_DEFAULT will be used as the ref spec template.
        Returns:
        this for 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:
        this for 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 (null or the empty string are equivalent to passing AbstractGitSCMSource.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 eventual remote() 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 to AbstractGitSCMSource.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 eventual remote() 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 to AbstractGitSCMSource.REF_SPEC_DEFAULT
        Returns:
        this for method chaining.
      • asRefSpecs

        @NonNull
        public final List<org.eclipse.jgit.transport.RefSpec> asRefSpecs()
        Converts the ref spec templates into RefSpec instances.
        Returns:
        the list of RefSpec instances.
      • build

        @NonNull
        public GitSCM build()
        Specified by:
        build in class jenkins.scm.api.trait.SCMBuilder<B extends GitSCMBuilder<B>,​GitSCM>