Skip to content

Commit 234f09b

Browse files
committed
[JENKINS-73797] Revert "Decorate GitClient after adding credentials (#1649)"
https://issues.jenkins.io/browse/JENKINS-73797 reports that Bitbucket branch source plugin multibranch Pipelines are broken by this change if they use ssh access to the repository. Rather than disrupt users by breaking their Pipelines, revert the change and release it so that we have time to evaluate alternatives and to develop better tests. This reverts commit 843d48b.
1 parent ca0612e commit 234f09b

File tree

2 files changed

+3
-44
lines changed

2 files changed

+3
-44
lines changed

src/main/java/hudson/plugins/git/GitSCM.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ private GitClient createClient(TaskListener listener, EnvVars environment, @NonN
912912
Git git = Git.with(listener, environment).in(ws).using(gitExe);
913913

914914
GitClient c = git.getClient();
915+
for (GitSCMExtension ext : extensions) {
916+
c = ext.decorate(this,c);
917+
}
915918

916919
for (UserRemoteConfig uc : getUserRemoteConfigs()) {
917920
String ucCredentialsId = uc.getCredentialsId();
@@ -935,10 +938,6 @@ private GitClient createClient(TaskListener listener, EnvVars environment, @NonN
935938
}
936939
// TODO add default credentials
937940

938-
for (GitSCMExtension ext : extensions) {
939-
c = ext.decorate(this,c);
940-
}
941-
942941
return c;
943942
}
944943

src/test/java/hudson/plugins/git/GitSCMTest.java

-40
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.cloudbees.plugins.credentials.CredentialsStore;
66
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
77
import com.cloudbees.plugins.credentials.common.StandardCredentials;
8-
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
98
import com.cloudbees.plugins.credentials.domains.Domain;
109
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
1110
import org.htmlunit.html.HtmlPage;
@@ -2916,30 +2915,6 @@ public void testCommitMessageIsPrintedToLogs() throws Exception {
29162915
r.waitForMessage("Commit message: \"test commit\"", run);
29172916
}
29182917

2919-
@Issue("JENKINS-73677")
2920-
@Test
2921-
public void testExtensionsDecorateClientAfterSettingCredentials() throws Exception {
2922-
assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable());
2923-
FreeStyleProject project = setupSimpleProject("master");
2924-
StandardCredentials extensionCredentials = createCredential(CredentialsScope.GLOBAL, "github");
2925-
store.addCredentials(Domain.global(), extensionCredentials);
2926-
// setup global config
2927-
List<UserRemoteConfig> remoteConfigs = GitSCM.createRepoList("https://github.com/jenkinsci/git-plugin", null);
2928-
project.setScm(new GitSCM(
2929-
remoteConfigs,
2930-
Collections.singletonList(new BranchSpec("master")),
2931-
false,
2932-
null,
2933-
null,
2934-
null,
2935-
List.of(new TestSetCredentialsGitSCMExtension((StandardUsernameCredentials) extensionCredentials))));
2936-
sampleRepo.init();
2937-
sampleRepo.write("file", "v1");
2938-
sampleRepo.git("commit", "--all", "--message=test commit");
2939-
Run<?, ?> run = r.buildAndAssertSuccess(project);
2940-
r.waitForMessage("using GIT_ASKPASS to set credentials " + extensionCredentials.getDescription(), run);
2941-
}
2942-
29432918
private void setupJGit(GitSCM git) {
29442919
git.gitTool="jgit";
29452920
r.jenkins.getDescriptorByType(GitTool.DescriptorImpl.class).setInstallations(new JGitTool(Collections.emptyList()));
@@ -2973,19 +2948,4 @@ private boolean isWindows() {
29732948
private StandardCredentials createCredential(CredentialsScope scope, String id) {
29742949
return new UsernamePasswordCredentialsImpl(scope, id, "desc: " + id, "username", "password");
29752950
}
2976-
2977-
public static class TestSetCredentialsGitSCMExtension extends GitSCMExtension {
2978-
2979-
private final StandardUsernameCredentials credentials;
2980-
2981-
public TestSetCredentialsGitSCMExtension(StandardUsernameCredentials credentials) {
2982-
this.credentials = credentials;
2983-
}
2984-
2985-
@Override
2986-
public GitClient decorate(GitSCM scm, GitClient git) throws GitException {
2987-
git.setCredentials(credentials);
2988-
return git;
2989-
}
2990-
}
29912951
}

0 commit comments

Comments
 (0)