Skip to content

Commit

Permalink
[JENKINS-12599] Changing how password is set in connections so as not to
Browse files Browse the repository at this point in the history
modify port numbers (as per comments #2 and #3)
[JENKINS-753] Stop processing if update fails and we're not going to do
a workspace clean
  • Loading branch information
mc1arke committed Feb 5, 2012
1 parent 794afd7 commit 1ccef67
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions src/main/java/hudson/scm/CVSSCM.java
Expand Up @@ -87,6 +87,7 @@
import org.netbeans.lib.cvsclient.connection.Connection;
import org.netbeans.lib.cvsclient.connection.ConnectionFactory;
import org.netbeans.lib.cvsclient.connection.PServerConnection;
import org.netbeans.lib.cvsclient.connection.StandardScrambler;
import org.netbeans.lib.cvsclient.event.CVSListener;

/**
Expand Down Expand Up @@ -555,33 +556,16 @@ private String getRemoteLogForModule(final CvsRepository repository, final CvsMo
* @return a CVS client capable of connecting to the specified repository
*/
public Client getCvsClient(final CvsRepository repository, final EnvVars envVars) {
CVSRoot cvsRoot = CVSRoot.parse(envVars.expand(repository.getCvsRoot()));

if (repository.isPasswordRequired()) {
/*
* cvsRoot.setPassword(...) isn't visible to us so rather than fiddle about with reflection
* we'll copy all fields to a properties object, set the custom password and then parse the
* properties to create a new cvsRoot
*/
Properties connectionProperties = new Properties();
connectionProperties.setProperty("method", cvsRoot.getMethod());
connectionProperties.setProperty("hostname", cvsRoot.getHostName());
connectionProperties.setProperty("username", cvsRoot.getUserName());
connectionProperties.setProperty("password", Secret.toString(repository.getPassword()));
if (cvsRoot.getPort() > 0) {
connectionProperties.setProperty("port", "" + cvsRoot.getPort());
} else {
connectionProperties.setProperty("port", "" + PServerConnection.DEFAULT_PORT);
}
connectionProperties.setProperty("repository", cvsRoot.getRepository());
cvsRoot = CVSRoot.parse(connectionProperties);
}
final CVSRoot cvsRoot = CVSRoot.parse(envVars.expand(repository.getCvsRoot()));

final Connection cvsConnection = ConnectionFactory.getConnection(cvsRoot);

final Client cvsClient = new Client(cvsConnection, new StandardAdminHandler());
if (repository.isPasswordRequired() && cvsConnection instanceof PServerConnection) {
((PServerConnection) cvsConnection).setEncodedPassword(
StandardScrambler.getInstance().scramble(Secret.toString(repository.getPassword())));
}

return cvsClient;
return new Client(cvsConnection, new StandardAdminHandler());
}

public GlobalOptions getGlobalOptions(CvsRepository repository, EnvVars envVars) {
Expand Down Expand Up @@ -761,7 +745,11 @@ public boolean checkout(final AbstractBuild<?, ?> build, final Launcher launcher
}

if (!perform(updateCommand, targetWorkspace, listener, repository, moduleName, envVars)) {
updateFailed = true;
if (cleanOnFailedUpdate) {
updateFailed = true;
} else {
return false;
}
}

}
Expand Down

0 comments on commit 1ccef67

Please sign in to comment.