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
Builds a
GitSCM
for GitHubSCMSource
.- Since:
- 2.2.0
-
Constructor Summary
ConstructorDescriptionGitHubSCMBuilder
(GitHubSCMSource source, jenkins.scm.api.SCMHead head, jenkins.scm.api.SCMRevision revision) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionhudson.plugins.git.GitSCM
build()
final String
repositoryUrl
(String owner, String repo) Tries as best as possible to guess the repository HTML url to use withGithubWeb
.final RepositoryUriResolver
Returns aRepositoryUriResolver
according to credentials configuration.static RepositoryUriResolver
uriResolver
(Item context, String apiUri, String credentialsId) Returns aRepositoryUriResolver
according to credentials configuration.withCredentials
(String credentialsId, RepositoryUriResolver uriResolver) Deprecated.final GitHubSCMBuilder
Updates theGitSCMBuilder.withRemote(String)
based on the currentSCMBuilder.head()
andSCMBuilder.revision()
.withResolver
(RepositoryUriResolver uriResolver) 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
-
Constructor Details
-
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 Details
-
repositoryUrl
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
Returns aRepositoryUriResolver
according to credentials configuration.- Returns:
- a
RepositoryUriResolver
-
withCredentials
@Deprecated @NonNull public GitHubSCMBuilder withCredentials(String credentialsId, RepositoryUriResolver uriResolver) Deprecated.UseGitSCMBuilder.withCredentials(String)
andwithResolver(RepositoryUriResolver)
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.
-
withResolver
-
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
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>
-
GitSCMBuilder.withCredentials(String)
andwithResolver(RepositoryUriResolver)