Skip to content

Commit

Permalink
[JENKINS-63307] Allow z/OS custom character set for password file
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Aug 8, 2020
1 parent 00728a3 commit 2fc643d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ Command line git 2.20 and later do not update an existing tag if the remote tag
+
Default is `true` so that newer command line git versions behave the same as older versions.

password.file.encoding::
When `org.jenkinsci.plugins.gitclient.CliGitAPIImpl.password.file.encoding` is set to a non-empty value (like `IBM-1047`) and the agent is running on IBM zOS, the password file is written using that character set.
The character sets of other credential files are not changed.
The character sets on other operating systems are not changed.
+
Default is empty so that zOS file encoding behaves as it did previously.

promptForAuthentication::
When `org.jenkinsci.plugins.gitclient.CliGitAPIImpl.promptForAuthentication` is set to `true` it allows command line git versions 2.3 and later to prompt the user for authentication.
Command line git prompting for authentication should be rare, since Jenkins credentials should be managed through the credentials plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2187,8 +2187,13 @@ private File createUsernameFile(StandardUsernamePasswordCredentials userPass) th
}

private File createPasswordFile(StandardUsernamePasswordCredentials userPass) throws IOException {
String charset = "UTF-8";
if (isZos() && System.getProperty(CliGitAPIImpl.class.getName() + ".password.file.encoding") != null) {
charset = Charset.forName(System.getProperty(CliGitAPIImpl.class.getName() + ".credentials.file.encoding")).toString();
listener.getLogger().println("Using password charset '" + charset + "'");
}
File passwordFile = createTempFile("password", ".txt");
try (PrintWriter w = new PrintWriter(passwordFile, "UTF-8")) {
try (PrintWriter w = new PrintWriter(passwordFile, charset)) {
w.println(Secret.toString(userPass.getPassword()));
}
return passwordFile;
Expand Down

0 comments on commit 2fc643d

Please sign in to comment.