Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-21916] Use credentials on rebase an integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
hugueschabot committed Feb 25, 2014
1 parent bec2aaa commit be299d5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/jenkins/plugins/svnmerge/FeatureBranchProperty.java
Expand Up @@ -15,10 +15,12 @@
import hudson.scm.SCM;
import hudson.scm.SubversionEventHandlerImpl;
import hudson.scm.SubversionSCM;
import hudson.scm.SvnClientManager;
import hudson.scm.SubversionSCM.ModuleLocation;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.tmatesoft.svn.core.ISVNLogEntryHandler;
Expand Down Expand Up @@ -144,8 +146,9 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
* (typically this means a merge conflict.)
*/
public long rebase(final TaskListener listener, final long upstreamRev) throws IOException, InterruptedException {
final ISVNAuthenticationProvider provider = Jenkins.getInstance().getDescriptorByType(
SubversionSCM.DescriptorImpl.class).createAuthenticationProvider();
final SubversionSCM svn = (SubversionSCM) getOwner().getScm();
final ISVNAuthenticationProvider provider = svn.createAuthenticationProvider(getOwner(), svn.getLocations()[0]);

return owner.getModuleRoot().act(new FileCallable<Long>() {
public Long invoke(File mr, VirtualChannel virtualChannel) throws IOException {
try {
Expand All @@ -160,8 +163,10 @@ public void handleEvent(SVNEvent event, double progress) throws SVNException {
}
};

SvnClientManager svnm = SubversionSCM.createClientManager(provider);

SVNURL up = getUpstreamURL();
SVNClientManager cm = SubversionSCM.createSvnClientManager(provider);
SVNClientManager cm = svnm.getCore();
cm.setEventHandler(printHandler);

SVNWCClient wc = cm.getWCClient();
Expand Down Expand Up @@ -242,8 +247,9 @@ public IntegrationResult(long mergeCommit, SVNRevision integrationSource) {
public IntegrationResult integrate(final TaskListener listener, final String branchURL, final long branchRev, final String commitMessage) throws IOException, InterruptedException {
final Long lastIntegrationSourceRevision = getlastIntegrationSourceRevision();

final ISVNAuthenticationProvider provider = Jenkins.getInstance().getDescriptorByType(
SubversionSCM.DescriptorImpl.class).createAuthenticationProvider();
final SubversionSCM svn = (SubversionSCM) getUpstreamProject().getScm();
final ISVNAuthenticationProvider provider = svn.createAuthenticationProvider(getUpstreamProject(), svn.getLocations()[0]);

return owner.getModuleRoot().act(new FileCallable<IntegrationResult>() {
public IntegrationResult invoke(File mr, VirtualChannel virtualChannel) throws IOException {
try {
Expand All @@ -258,8 +264,10 @@ public void handleEvent(SVNEvent event, double progress) throws SVNException {
}
};

SvnClientManager svnm = SubversionSCM.createClientManager(provider);

SVNURL up = getUpstreamURL();
SVNClientManager cm = SubversionSCM.createSvnClientManager(provider);
SVNClientManager cm = svnm.getCore();
cm.setEventHandler(printHandler);

// capture the working directory state before the switch
Expand Down

0 comments on commit be299d5

Please sign in to comment.