Skip to content
Permalink
Browse files
Merge pull request #543 from stephenc/jenkins-47526
[JENKINS-47526] Provide an API to allow an AbstractGitSCMSource to work at a distance from the repository rather than requiring a local checkout
  • Loading branch information
MarkEWaite committed Oct 23, 2017
2 parents c5fbe73 + f7f9310 commit a82b46dd16e962e21b668008c5f56127f9e7af75
Showing 4 changed files with 1,221 additions and 6 deletions.
@@ -18,6 +18,8 @@
import hudson.model.*;
import hudson.model.Descriptor.FormException;
import hudson.model.Hudson.MasterComputer;
import hudson.model.Queue;
import hudson.model.queue.Tasks;
import hudson.plugins.git.browser.GitRepositoryBrowser;
import hudson.plugins.git.extensions.GitClientConflictException;
import hudson.plugins.git.extensions.GitClientType;
@@ -762,8 +764,14 @@ public GitClient createClient(TaskListener listener, EnvVars environment, Run<?,
String ucCredentialsId = uc.getCredentialsId();
if (ucCredentialsId != null) {
String url = getParameterString(uc.getUrl(), environment);
List<StandardUsernameCredentials> urlCredentials = CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, project,
ACL.SYSTEM, URIRequirementBuilder.fromUri(url).build());
List<StandardUsernameCredentials> urlCredentials = CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
project,
project instanceof Queue.Task
? Tasks.getDefaultAuthenticationOf((Queue.Task)project)
: ACL.SYSTEM,
URIRequirementBuilder.fromUri(url).build()
);
CredentialsMatcher ucMatcher = CredentialsMatchers.withId(ucCredentialsId);
CredentialsMatcher idMatcher = CredentialsMatchers.allOf(ucMatcher, GitClient.CREDENTIALS_MATCHER);
StandardUsernameCredentials credentials = CredentialsMatchers.firstOrNull(urlCredentials, idMatcher);

0 comments on commit a82b46d

Please sign in to comment.