Class GitHubSCMBuilder

    • Constructor Detail

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

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