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 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

      @Deprecated @NonNull public GitHubSCMBuilder withCredentials(String credentialsId, RepositoryUriResolver uriResolver)
      Deprecated.
      Use GitSCMBuilder.withCredentials(String) and withResolver(RepositoryUriResolver)
      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.
    • withResolver

      @NonNull public GitHubSCMBuilder withResolver(RepositoryUriResolver uriResolver)
    • 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>