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
Stop recommending -jnlpUrl
#8639
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
|
||
package hudson.slaves; | ||
|
||
import com.google.common.escape.Escaper; | ||
import com.google.common.escape.Escapers; | ||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
@@ -38,6 +40,7 @@ | |
import jenkins.slaves.RemotingWorkDirSettings; | ||
import jenkins.util.SystemProperties; | ||
import jenkins.websocket.WebSockets; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
@@ -195,6 +198,59 @@ | |
@Restricted(NoExternalUse.class) | ||
public static /*almost final*/ Descriptor<ComputerLauncher> DESCRIPTOR; | ||
|
||
@NonNull | ||
@Restricted(NoExternalUse.class) | ||
public String getRemotingOptionsUnix(@NonNull Computer computer) { | ||
return getRemotingOptions(escapeUnix(computer.getName())); | ||
} | ||
|
||
@NonNull | ||
@Restricted(NoExternalUse.class) | ||
public String getRemotingOptionsWindows(@NonNull Computer computer) { | ||
return getRemotingOptions(escapeWindows(computer.getName())); | ||
} | ||
|
||
private String getRemotingOptions(String computerName) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("-name "); | ||
sb.append(computerName); | ||
sb.append(' '); | ||
if (isWebSocket()) { | ||
sb.append("-webSocket "); | ||
} | ||
if (tunnel != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Also |
||
sb.append(" -tunnel "); | ||
sb.append(tunnel); | ||
sb.append(' '); | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* {@link Jenkins#checkGoodName(String)} saves us from most troublesome characters, but we still have to deal with | ||
* spaces and therefore with double quotes and backticks. | ||
*/ | ||
private static String escapeUnix(String input) { | ||
if (StringUtils.isAlphanumeric(input)) { | ||
return input; | ||
} | ||
Escaper escaper = | ||
Escapers.builder().addEscape('"', "\\\"").addEscape('`', "\\`").build(); | ||
return "\"" + escaper.escape(input) + "\""; | ||
} | ||
|
||
/** | ||
* {@link Jenkins#checkGoodName(String)} saves us from most troublesome characters, but we still have to deal with | ||
* spaces and therefore with double quotes. | ||
*/ | ||
private static String escapeWindows(String input) { | ||
if (StringUtils.isAlphanumeric(input)) { | ||
return input; | ||
} | ||
Escaper escaper = Escapers.builder().addEscape('"', "\\\"").build(); | ||
return "\"" + escaper.escape(input) + "\""; | ||
} | ||
|
||
/** | ||
* Gets work directory options as a String. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simply deprecate this option, since it will now have no effect other than changing the recommendation for the command if you take the advice to stop using
-jnlpUrl
. Compare discussion ofvmargs
in #6543.