Skip to content

Commit

Permalink
Merge pull request #66 from matthauck/add-pass-file
Browse files Browse the repository at this point in the history
Add a passwordFile option
  • Loading branch information
oleg-nenashev committed Feb 2, 2018
2 parents 1b11e66 + 86896c4 commit 5ce68e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/src/main/java/hudson/plugins/swarm/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.kohsuke.args4j.CmdLineParser;

import javax.xml.parsers.ParserConfigurationException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -84,6 +86,11 @@ public static void main(String... args) throws InterruptedException, IOException
if (options.passwordEnvVariable != null) {
options.password = System.getenv(options.passwordEnvVariable);
}
// read pass from file if no other password was specified
if (options.password == null && options.passwordFile != null) {
options.password = new String(Files.readAllBytes(Paths.get(options.passwordFile)), "UTF-8");
}


// Only look up the hostname if we have not already specified
// name of the slave. Also in certain cases this lookup might fail.
Expand Down
3 changes: 3 additions & 0 deletions client/src/main/java/hudson/plugins/swarm/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public class Options {
@Option(name = "-passwordEnvVariable", usage = "Environment variable that the password is stored in")
public String passwordEnvVariable;

@Option(name = "-passwordFile", usage = "File containing the Jenkins user password")
public String passwordFile;

@Option(name = "-showHostName", aliases = "--showHostName", usage = "Show hostnames instead of IP address")
public boolean showHostName;

Expand Down

0 comments on commit 5ce68e6

Please sign in to comment.