Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ public String getScript() {

OsType os = agentInfo.getOs();
String scriptEncodingCharset = "UTF-8";
String jenkinsResultTxtEncoding = null;
if(os == OsType.ZOS) {
Charset zOSSystemEncodingCharset = Charset.forName(ws.act(new getIBMzOsEncoding()));
if(SYSTEM_DEFAULT_CHARSET.equals(getCharset())) {
// Setting default charset to IBM z/OS default EBCDIC charset on z/OS if no encoding specified on sh step
charset(zOSSystemEncodingCharset);
}
scriptEncodingCharset = zOSSystemEncodingCharset.name();
jenkinsResultTxtEncoding = zOSSystemEncodingCharset.name();
}

ShellController c = new ShellController(ws,(os == OsType.ZOS), cookieValue);
ShellController c = new ShellController(ws,(os == OsType.ZOS), cookieValue, jenkinsResultTxtEncoding);
FilePath shf = c.getScriptFile(ws);

shf.write(script, scriptEncodingCharset);
Expand Down Expand Up @@ -275,10 +277,13 @@ private List<String> scriptLauncherCmd(ShellController c, FilePath ws, @CheckFor

/** Caching zOS flag to avoid round trip calls in exitStatus() */
private final boolean isZos;
/** Encoding of jenkins-result.txt if on z/OS, null otherwise */
private String jenkinsResultTxtEncoding;

private ShellController(FilePath ws, boolean zOsFlag, @NonNull String cookieValue) throws IOException, InterruptedException {
private ShellController(FilePath ws, boolean zOsFlag, @NonNull String cookieValue, String jenkinsResultTxtEncoding) throws IOException, InterruptedException {
super(ws, cookieValue);
this.isZos = zOsFlag;
this.jenkinsResultTxtEncoding = jenkinsResultTxtEncoding;
}

public FilePath getScriptFile(FilePath ws) throws IOException, InterruptedException {
Expand All @@ -295,7 +300,7 @@ private FilePath pidFile(FilePath ws) throws IOException, InterruptedException {
if(isZos) {
// We need to transcode status file from EBCDIC only on z/OS platform
FilePath statusFile = getResultFile(workspace);
status = statusFile.act(new StatusCheckWithEncoding(getCharset()));
status = statusFile.act(new StatusCheckWithEncoding(jenkinsResultTxtEncoding != null ? jenkinsResultTxtEncoding : getCharset()));
}
else {
status = super.exitStatus(workspace, listener);
Expand Down Expand Up @@ -385,7 +390,7 @@ public Integer invoke(File f, VirtualChannel channel) throws IOException, Interr
}
}
} catch (NumberFormatException x) {
throw new IOException("corrupted content in " + f + ": " + x, x);
throw new IOException("corrupted content in " + f + " using " + charset + ": " + x, x);
}
}
return null;
Expand Down