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 aGitSCM
forGitHubSCMSource
.- 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description hudson.plugins.git.GitSCM
build()
String
repositoryUrl(String owner, String repo)
Tries as best as possible to guess the repository HTML url to use withGithubWeb
.RepositoryUriResolver
uriResolver()
Returns aRepositoryUriResolver
according to credentials configuration.static RepositoryUriResolver
uriResolver(Item context, String apiUri, String credentialsId)
Returns aRepositoryUriResolver
according to credentials configuration.GitHubSCMBuilder
withCredentials(String credentialsId, RepositoryUriResolver uriResolver)
Configures theIdCredentials.getId()
of theCredentials
to use when connecting to theGitSCMBuilder.remote()
GitHubSCMBuilder
withGitHubRemote()
Updates theGitSCMBuilder.withRemote(String)
based on the currentSCMBuilder.head()
andSCMBuilder.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
-
-
-
-
Constructor Detail
-
GitHubSCMBuilder
public GitHubSCMBuilder(@NonNull GitHubSCMSource source, @NonNull jenkins.scm.api.SCMHead head, @CheckForNull jenkins.scm.api.SCMRevision revision)
Constructor.- Parameters:
source
- theGitHubSCMSource
.head
- theSCMHead
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 withGithubWeb
.- 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 aRepositoryUriResolver
according to credentials configuration.- Returns:
- a
RepositoryUriResolver
-
withCredentials
@NonNull public GitHubSCMBuilder withCredentials(String credentialsId, RepositoryUriResolver uriResolver)
Configures theIdCredentials.getId()
of theCredentials
to use when connecting to theGitSCMBuilder.remote()
- Parameters:
credentialsId
- theIdCredentials.getId()
of theCredentials
to use when connecting to theGitSCMBuilder.remote()
ornull
to let the git client choose between providing its own credentials or connecting anonymously.uriResolver
- theRepositoryUriResolver
of theCredentials
to use ornull
to detect the the protocol based on the credentialsId. Defaults to HTTP if credentials arenull
. 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 aRepositoryUriResolver
according to credentials configuration.- Parameters:
context
- the context within which to resolve the credentials.apiUri
- the API urlcredentialsId
- the credentials.- Returns:
- a
RepositoryUriResolver
-
withGitHubRemote
@NonNull public final GitHubSCMBuilder withGitHubRemote()
Updates theGitSCMBuilder.withRemote(String)
based on the currentSCMBuilder.head()
andSCMBuilder.revision()
.Will be called automatically by
build()
but exposed in case the correct remote is required after changing theGitSCMBuilder.withCredentials(String)
.- Returns:
this
for method chaining.
-
build
@NonNull public hudson.plugins.git.GitSCM build()
- Overrides:
build
in classjenkins.plugins.git.GitSCMBuilder<GitHubSCMBuilder>
-
-