Class GitHubSCMBuilder

java.lang.Object
jenkins.scm.api.trait.SCMBuilder<B,hudson.plugins.git.GitSCM>
jenkins.plugins.git.GitSCMBuilder<GitHubSCMBuilder>
org.jenkinsci.plugins.github_branch_source.GitHubSCMBuilder

public class GitHubSCMBuilder extends jenkins.plugins.git.GitSCMBuilder<GitHubSCMBuilder>
Builds a GitSCM for GitHubSCMSource.
Since:
2.2.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    GitHubSCMBuilder(GitHubSCMSource source, jenkins.scm.api.SCMHead head, jenkins.scm.api.SCMRevision revision)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    hudson.plugins.git.GitSCM
    final String
    repositoryUrl(String owner, String repo)
    Tries as best as possible to guess the repository HTML url to use with GithubWeb.
    Returns a RepositoryUriResolver according to credentials configuration.
    uriResolver(Item context, String apiUri, String credentialsId)
    Returns a RepositoryUriResolver according to credentials configuration.
    withCredentials(String credentialsId, RepositoryUriResolver uriResolver)
    Configures the IdCredentials.getId() of the Credentials to use when connecting to the GitSCMBuilder.remote()
    Updates the GitSCMBuilder.withRemote(String) based on the current SCMBuilder.head() and SCMBuilder.revision().

    Methods inherited from class jenkins.plugins.git.GitSCMBuilder

    additionalRemote, additionalRemoteNames, additionalRemoteRefSpecs, asRefSpecs, asRemoteConfigs, browser, credentialsId, extensions, gitTool, refSpecs, remote, remoteName, withAdditionalRemote, withAdditionalRemote, withBrowser, withCredentials, withExtension, withExtensions, withExtensions, withGitTool, withoutRefSpecs, withRefSpec, withRefSpecs, withRemote, withRemoteName

    Methods inherited from class jenkins.scm.api.trait.SCMBuilder

    head, revision, scmClass, withHead, withRevision, withTrait, withTraits, withTraits

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GitHubSCMBuilder

      public GitHubSCMBuilder(@NonNull GitHubSCMSource source, @NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMRevision revision)
      Constructor.
      Parameters:
      source - the GitHubSCMSource.
      head - the SCMHead
      revision - the (optional) SCMRevision
  • Method Details

    • repositoryUrl

      @CheckForNull public final String repositoryUrl(String owner, String repo)
      Tries as best as possible to guess the repository HTML url to use with GithubWeb.
      Parameters:
      owner - the owner.
      repo - the repository.
      Returns:
      the HTML url of the repository or null if we could not determine the answer.
    • uriResolver

      @NonNull public final RepositoryUriResolver uriResolver()
      Returns a RepositoryUriResolver according to credentials configuration.
      Returns:
      a RepositoryUriResolver
    • withCredentials

      @NonNull public GitHubSCMBuilder withCredentials(String credentialsId, RepositoryUriResolver uriResolver)
      Configures the IdCredentials.getId() of the Credentials to use when connecting to the GitSCMBuilder.remote()
      Parameters:
      credentialsId - the IdCredentials.getId() of the Credentials to use when connecting to the GitSCMBuilder.remote() or null to let the git client choose between providing its own credentials or connecting anonymously.
      uriResolver - the RepositoryUriResolver of the Credentials to use or null to detect the the protocol based on the credentialsId. Defaults to HTTP if credentials are null. Enables support for blank SSH credentials.
      Returns:
      this for method chaining.
    • uriResolver

      @NonNull public static RepositoryUriResolver uriResolver(@CheckForNull Item context, @NonNull String apiUri, @CheckForNull String credentialsId)
      Returns a RepositoryUriResolver according to credentials configuration.
      Parameters:
      context - the context within which to resolve the credentials.
      apiUri - the API url
      credentialsId - the credentials.
      Returns:
      a RepositoryUriResolver
    • withGitHubRemote

      @NonNull public final GitHubSCMBuilder withGitHubRemote()
      Updates the GitSCMBuilder.withRemote(String) based on the current SCMBuilder.head() and SCMBuilder.revision().

      Will be called automatically by build() but exposed in case the correct remote is required after changing the GitSCMBuilder.withCredentials(String).

      Returns:
      this for method chaining.
    • build

      @NonNull public hudson.plugins.git.GitSCM build()
      Overrides:
      build in class jenkins.plugins.git.GitSCMBuilder<GitHubSCMBuilder>