Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing code to support the Remoting-based CLI #3838

Merged
merged 13 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 7 additions & 437 deletions cli/src/main/java/hudson/cli/CLI.java

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions cli/src/main/java/hudson/cli/CLIConnectionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,15 @@

import org.apache.commons.codec.binary.Base64;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ExecutorService;

/**
* Fluent-API to instantiate {@link CLI}.
*
* @author Kohsuke Kawaguchi
*/
public class CLIConnectionFactory {
URL jenkins;
ExecutorService exec;
String httpsProxyTunnel;
String authorization;

/**
* Top URL of the Jenkins to connect to.
*/
public CLIConnectionFactory url(URL jenkins) {
this.jenkins = jenkins;
return this;
}

public CLIConnectionFactory url(String jenkins) throws MalformedURLException {
return url(new URL(jenkins));
}

/**
* This {@link ExecutorService} is used to execute closures received from the server.
* Used only in Remoting mode.
*/
public CLIConnectionFactory executorService(ExecutorService es) {
this.exec = es;
return this;
}

/**
* Configures the HTTP proxy that we use for making a plain TCP/IP connection.
* "host:port" that points to an HTTP proxy or null.
*/
public CLIConnectionFactory httpsProxyTunnel(String value) {
this.httpsProxyTunnel = value;
return this;
}

/**
* For CLI connection that goes through HTTP, sometimes you need
* to pass in the custom authentication header (before Jenkins even get to authenticate
Expand All @@ -74,11 +37,4 @@ public CLIConnectionFactory basicAuth(String userInfo) {
return authorization("Basic " + new String(Base64.encodeBase64((userInfo).getBytes())));
}

/**
* @deprecated Specific to Remoting-based protocol.
*/
@Deprecated
public CLI connect() throws IOException, InterruptedException {
return new CLI(this);
}
}
75 changes: 0 additions & 75 deletions cli/src/main/java/hudson/cli/CliEntryPoint.java

This file was deleted.

44 changes: 0 additions & 44 deletions cli/src/main/java/hudson/cli/CliPort.java

This file was deleted.

3 changes: 2 additions & 1 deletion cli/src/main/java/hudson/cli/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
import org.jenkinsci.remoting.util.AnonymousClassWarnings;

/**
* Used by Jenkins core only in deprecated Remoting-based CLI.
* @deprecated No longer used.
*/
@Deprecated
public class Connection {
public final InputStream in;
public final OutputStream out;
Expand Down
29 changes: 0 additions & 29 deletions cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.codec.binary.Base64;

/**
* Creates a capacity-unlimited bi-directional {@link InputStream}/{@link OutputStream} pair over
* HTTP, which is a request/response protocol.
Expand All @@ -19,10 +17,6 @@
*/
public class FullDuplexHttpStream {
private final URL base;
/**
* Authorization header value needed to get through the HTTP layer.
*/
private final String authorization;

private final OutputStream output;
private final InputStream input;
Expand All @@ -43,28 +37,6 @@ public OutputStream getOutputStream() {
return output;
}

@Deprecated
public FullDuplexHttpStream(URL target) throws IOException {
this(target,basicAuth(target.getUserInfo()));
}

private static String basicAuth(String userInfo) {
if (userInfo != null)
return "Basic "+new String(Base64.encodeBase64(userInfo.getBytes()));
return null;
}

/**
* @param target something like {@code http://jenkins/cli?remoting=true}
* which we then need to split into {@code http://jenkins/} + {@code cli?remoting=true}
* in order to construct a crumb issuer request
* @deprecated use {@link #FullDuplexHttpStream(URL, String, String)} instead
*/
@Deprecated
public FullDuplexHttpStream(URL target, String authorization) throws IOException {
this(new URL(target.toString().replaceFirst("/cli.*$", "/")), target.toString().replaceFirst("^.+/(cli.*)$", "$1"), authorization);
}

/**
* @param base the base URL of Jenkins
* @param relativeTarget
Expand All @@ -81,7 +53,6 @@ public FullDuplexHttpStream(URL base, String relativeTarget, String authorizatio
}

this.base = tryToResolveRedirects(base, authorization);
this.authorization = authorization;

URL target = new URL(this.base, relativeTarget);

Expand Down
9 changes: 3 additions & 6 deletions cli/src/main/resources/hudson/cli/client/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ CLI.Usage=Jenkins CLI\n\
Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...\n\
Options:\n\
\ -s URL : the server URL (defaults to the JENKINS_URL env var)\n\
\ -http : use a plain CLI protocol over HTTP(S) (the default; mutually exclusive with -ssh and -remoting)\n\
\ -http : use a plain CLI protocol over HTTP(S) (the default; mutually exclusive with -ssh)\n\
\ -ssh : use SSH protocol (requires -user; SSH port must be open on server, and user must have registered a public key)\n\
\ -remoting : use deprecated Remoting channel protocol (if enabled on server; for compatibility with legacy commands or command modes only)\n\
\ -i KEY : SSH private key file used for authentication (for use with -ssh or -remoting)\n\
\ -p HOST:PORT : HTTP proxy host and port for HTTPS proxy tunneling. See https://jenkins.io/redirect/cli-https-proxy-tunnel\n\
\ -i KEY : SSH private key file used for authentication (for use with -ssh)\n\
\ -noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution\n\
\ -noKeyAuth : don't try to load the SSH authentication private key. Conflicts with -i\n\
\ -user : specify user (for use with -ssh)\n\
\ -strictHostKey : request strict host key checking (for use with -ssh)\n\
\ -logger FINE : enable detailed logging from the client\n\
\ -auth [ USER:SECRET | @FILE ] : specify username and either password or API token (or load from them both from a file);\n\
\ for use with -http, or -remoting but only when the JNLP agent port is disabled.\n\
\ Passing crendentials by a file is recommended.\n\
\ Passing credentials by file is recommended.\n\
\ See https://jenkins.io/redirect/cli-http-connection-mode for more info and options.\n\
\n\
The available commands depend on the server. Run the 'help' command to \
see the list.
CLI.NoURL=Neither -s nor the JENKINS_URL env var is specified.
CLI.VersionMismatch=Version mismatch. This CLI cannot work with this Jenkins server.
CLI.NoSuchFileExists=No such file exists: {0}
CLI.BadAuth=The JENKINS_USER_ID and JENKINS_API_TOKEN env vars should be both set or left empty.
56 changes: 0 additions & 56 deletions cli/src/test/java/hudson/cli/ConnectionMockTest.java

This file was deleted.

Loading