Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
added --paramsFromStdIn parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
arykov committed Jan 9, 2018
1 parent 31bd927 commit 4d6118b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -30,4 +30,12 @@ In such case it becomes configurable via [Jetty configuration](http://www.eclips
Sets a custom Session ID Cookie name when `disableCustomSessionIdCookieName` is `false`.
In such case the Jenkins administrator is responsible for preventing cookie collisions between Jenkins instances.

### Parameters from stdin

When parameters are passed via command line they can be viewed using ps in *nix, process explorer in Windows as long as the process keeps running. This is undesirable when passing sensitive parameters like httpsKeyStorePassword.

It is now possible to pass parameters through stdin. To do this pass '--paramsFromStdIn' parameter and you will be able to replace this:
`java -jar jenkins.war --httpPort=-1 --httpsPort=443 --httpsKeyStore=path/to/keystore --httpsKeyStorePassword=keystorePassword`
with this:
`echo "--httpPort=-1 --httpsPort=443 --httpsKeyStore=path/to/keystore --httpsKeyStorePassword=keystorePassword" | java -jar jenkins.war --paramsFromStdIn`

11 changes: 8 additions & 3 deletions src/main/java/Main.java
Expand Up @@ -139,9 +139,14 @@ public static void main(String[] args) throws Exception {

private static void _main(String[] args) throws Exception {
//Allows to pass arguments through stdin to "hide" sensitive parameters like httpsKeyStorePassword
if(args.length == 0) {
String argsInStdIn = readStringNonBlocking(System.in,131072).trim();
args = argsInStdIn.split(" +");
//to achieve this use --paramsFromStdIn
for (String arg:args){
if ("--paramsFromStdIn".equals(arg)) {
System.out.println("--paramsFromStdIn detected. Parameters are going to be read from stdin. Other parameters passed directly will be ignored.");
String argsInStdIn = readStringNonBlocking(System.in,131072).trim();
args = argsInStdIn.split(" +");
break;
}
}
// If someone just wants to know the version, print it out as soon as possible, with no extraneous file or webroot info.
// This makes it easier to grab the version from a script
Expand Down

0 comments on commit 4d6118b

Please sign in to comment.