Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-40225] single remoting call
  • Loading branch information
blatinville committed Jan 16, 2017
1 parent 998f0bb commit 63b957b
Showing 1 changed file with 16 additions and 12 deletions.
Expand Up @@ -49,6 +49,8 @@
*/
public final class BourneShellScript extends FileMonitoringTask {

private static enum OsType {DARWIN, UNIX, WINDOWS}

/** Number of times we will show launch diagnostics in a newly encountered workspace before going mute to save resources. */
private static /* not final */ int NOVEL_WORKSPACE_DIAGNOSTICS_COUNT = Integer.getInteger(BourneShellScript.class.getName() + ".NOVEL_WORKSPACE_DIAGNOSTICS_COUNT", 10);
/** Number of seconds we will wait for a controller script to be launched before assuming the launch failed. */
Expand Down Expand Up @@ -101,11 +103,13 @@ public String getScript() {
scriptPath = shf.getRemote();
List<String> args = new ArrayList<String>();

if (!ws.act(new DarwinCheck())) { // JENKINS-25848
OsType os = ws.act(new getOsType());

if (os != OsType.DARWIN) { // JENKINS-25848
args.add("nohup");
}
if (ws.act(new WindowsCheck())) { // JENKINS-40255
scriptPath= scriptPath.replace("\\", "/"); // cygwin sh understands mixed path (ie : "c:/jenkins/workspace/script.sh" )
if (os == OsType.WINDOWS) { // JENKINS-40255
scriptPath= scriptPath.replace("\\", "/"); // cygwin sh understands mixed path (ie : "c:/jenkins/workspace/script.sh" )
}

envVars.put(cookieVariable, "please-do-not-kill-me");
Expand Down Expand Up @@ -221,15 +225,15 @@ private synchronized int pid(FilePath ws) throws IOException, InterruptedExcepti

}

private static final class DarwinCheck extends MasterToSlaveCallable<Boolean,RuntimeException> {
@Override public Boolean call() throws RuntimeException {
return Platform.isDarwin();
}
}
private static final class WindowsCheck extends MasterToSlaveCallable<Boolean,RuntimeException> {
@Override public Boolean call() throws RuntimeException {
return Platform.current() == Platform.WINDOWS ;
private static final class getOsType extends MasterToSlaveCallable<OsType,RuntimeException> {
@Override public OsType call() throws RuntimeException {
if (Platform.isDarwin()) {
return OsType.DARWIN;
} else if (Platform.current() == Platform.WINDOWS) {
return OsType.WINDOWS;
} else {
return OsType.UNIX; // Default Value
}
}
}

}

0 comments on commit 63b957b

Please sign in to comment.