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

Print deprecation warning when deprecated arguments are used #699

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
78 changes: 71 additions & 7 deletions src/main/java/hudson/remoting/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@
public class Launcher {
public Mode mode = Mode.BINARY;

// no-op, but left for backward compatibility
@Option(name="-ping")
/**
* @deprecated removed without replacement
*/
@Deprecated
public boolean ping = true;

/**
Expand All @@ -119,6 +121,17 @@ public void setTextMode(boolean b) {
System.out.println("Running in "+mode.name().toLowerCase(Locale.ENGLISH)+" mode");
}

/**
* @deprecated removed without replacement
*/
@Deprecated
@Option(name = "-ping", usage = "(deprecated; now always pings)")
public void setPing(boolean ping) {
this.ping = ping;
System.err.println(
"WARNING: The \"-ping\" argument is deprecated and will be removed without replacement in a future release.");
}

/**
* @deprecated use {@link #secret}, {@link #name}, {@link #urls}, {@link #webSocket}, {@link #tunnel},
* {@link #workDir}, {@link #internalDir}, and/or {@link #failIfWorkDirIsMissing} directly.
Expand All @@ -141,18 +154,42 @@ public void setTextMode(boolean b) {
@Option(name="-proxyCredentials",metaVar="USER:PASSWORD",usage="HTTP BASIC AUTH header to pass in for making HTTP authenticated proxy requests.")
public String proxyCredentials = System.getProperty("proxyCredentials");

@Option(name="-tcp",usage="instead of talking to the controller via stdin/stdout, " +
/**
* @deprecated removed without replacement
*/
@Deprecated
public File tcpPortFile = null;

/**
* @deprecated removed without replacement
*/
@Deprecated
@Option(name="-tcp",usage="(deprecated) instead of talking to the controller via stdin/stdout, " +
"listens to a random local port, write that port number to the given file, " +
"then wait for the controller to connect to that port.")
public File tcpPortFile=null;
public void setTcpPortFile(File tcpPortFile) {
this.tcpPortFile = tcpPortFile;
System.err.println(
"WARNING: The \"-tcp\" argument is deprecated and will be removed without replacement in a future release.");
}

/**
* @deprecated use {@link #agentJnlpCredentials} or {@link #proxyCredentials}
*/
@Deprecated
@Option(name="-auth",metaVar="user:pass",usage="(deprecated) unused; use -credentials or -proxyCredentials")
public String auth = null;

/**
* @deprecated use {@link #agentJnlpCredentials} or {@link #proxyCredentials}
*/
@Deprecated
@Option(name = "-auth", metaVar = "user:pass", usage = "(deprecated) unused; use -credentials or -proxyCredentials")
public void setAuth(String auth) {
this.auth = auth;
System.err.println(
"WARNING: The \"-auth\" argument is deprecated and will be removed in a future release; use \"-credentials\" or \"-proxyCredentials\" instead.");
}

/**
* @since 2.24
*/
Expand Down Expand Up @@ -187,16 +224,26 @@ public void setTextMode(boolean b) {

private HostnameVerifier hostnameVerifier;

/**
* @deprecated removed without replacement
*/
@Deprecated
public InetSocketAddress connectionTarget = null;

@Option(name="-connectTo",usage="make a TCP connection to the given host and port, then start communication.",metaVar="HOST:PORT")
/**
* @deprecated removed without replacement
*/
@Deprecated
@Option(name="-connectTo",usage="(deprecated) make a TCP connection to the given host and port, then start communication.",metaVar="HOST:PORT")
public void setConnectTo(String target) {
String[] tokens = target.split(":");
if(tokens.length!=2) {
System.err.println("Illegal parameter: "+target);
System.exit(1);
}
connectionTarget = new InetSocketAddress(tokens[0],Integer.parseInt(tokens[1]));
System.err.println(
"WARNING: The \"-connectTo\" argument is deprecated and will be removed without replacement in a future release.");
}

@Option(name="-noReconnect",aliases="-noreconnect",usage="Doesn't try to reconnect when a communication fail, and exit instead")
Expand Down Expand Up @@ -251,10 +298,23 @@ public void setConnectTo(String target) {
+ "in which case the missing portion will be auto-configured like the default behavior.")
public String tunnel;

/**
* @deprecated removed without replacement
*/
@Deprecated
@Option(name = "-headless", usage = "(deprecated; now always headless)")
public boolean headlessMode;

/**
* @deprecated removed without replacement
*/
@Deprecated
@Option(name = "-headless", usage = "(deprecated; now always headless)")
public void setHeadlessMode(boolean headlessMode) {
this.headlessMode = headlessMode;
System.err.println(
"WARNING: The \"-headless\" argument is deprecated and will be removed without replacement in a future release.");
}

@Option(name = "-url", usage = "Specify the Jenkins root URLs to connect to.")
public List<URL> urls = new ArrayList<>();

Expand Down Expand Up @@ -337,6 +397,10 @@ public static void main(String... args) throws IOException, InterruptedException
CmdLineParser parser = new CmdLineParser(launcher);
try {
parser.parseArgument(args);
if (launcher.args.size() == 2) {
System.err.println(
"WARNING: Providing the secret and agent name as positional arguments is deprecated; use \"-secret\" and \"-name\" instead.");
}
normalizeArguments(launcher);
if (launcher.showHelp && !launcher.showVersion) {
parser.printUsage(System.out);
Expand Down