Skip to content

Commit

Permalink
[JENKINS-23027] Using Launcher.ProcStarter.quiet when available.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Aug 8, 2014
1 parent 0b22af2 commit 6dc9930
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -74,7 +74,16 @@ public String getScript() {
c.getResultFile(ws)
);

launcher.launch().cmds("nohup", "sh", "-c", cmd).envs(envVars).pwd(ws).start();
Launcher.ProcStarter ps = launcher.launch().cmds("nohup", "sh", "-c", cmd).envs(envVars).pwd(ws);
try {
Launcher.ProcStarter.class.getMethod("quiet", boolean.class).invoke(ps, true); // TODO 1.576+ remove reflection
listener.getLogger().println("[" + ws.getRemote().replaceFirst("^.+/", "") + "] Running shell script"); // -x will give details
} catch (NoSuchMethodException x) {
// older Jenkins, OK
} catch (Exception x) { // ?
x.printStackTrace(listener.getLogger());
}
ps.start();
return c;
}

Expand Down
Expand Up @@ -59,7 +59,16 @@ public String getScript() {
), "UTF-8");
c.getBatchFile2(ws).write(script, "UTF-8");

launcher.launch().cmds("cmd", "/c", c.getBatchFile1(ws).getRemote()).envs(envVars).pwd(ws).start();
Launcher.ProcStarter ps = launcher.launch().cmds("cmd", "/c", c.getBatchFile1(ws).getRemote()).envs(envVars).pwd(ws);
try {
Launcher.ProcStarter.class.getMethod("quiet", boolean.class).invoke(ps, true); // TODO 1.576+ remove reflection
listener.getLogger().println("[" + ws.getRemote().replaceFirst("^.+\\\\", "") + "] Running batch script"); // details printed by cmd
} catch (NoSuchMethodException x) {
// older Jenkins, OK
} catch (Exception x) { // ?
x.printStackTrace(listener.getLogger());
}
ps.start();
return c;
}

Expand Down

0 comments on commit 6dc9930

Please sign in to comment.