Skip to content

Commit

Permalink
[FIXED JENKINS-25848] Skip nohup on Mac OS X, since it fails under so…
Browse files Browse the repository at this point in the history
…me conditions.
  • Loading branch information
jglick committed Dec 3, 2014
1 parent a655dc3 commit 1957d3f
Showing 1 changed file with 18 additions and 3 deletions.
Expand Up @@ -28,11 +28,15 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Platform;
import hudson.Util;
import hudson.model.TaskListener;
import java.io.IOException;

import hudson.remoting.Callable;
import hudson.tasks.Shell;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -76,7 +80,12 @@ public String getScript() {
c.getResultFile(ws)
)./* escape against EnvVars jobEnv in LocalLauncher.launch */replace("$", "$$");

Launcher.ProcStarter ps = launcher.launch().cmds("nohup", "sh", "-c", cmd).envs(envVars).pwd(ws);
List<String> args = new ArrayList<String>();
if (!ws.act(new DarwinCheck())) { // JENKINS-25848
args.add("nohup");
}
args.addAll(Arrays.asList("sh", "-c", cmd));
Launcher.ProcStarter ps = launcher.launch().cmds(args).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
Expand Down Expand Up @@ -152,4 +161,10 @@ private synchronized int pid(FilePath ws) throws IOException, InterruptedExcepti

}

private static final class DarwinCheck implements Callable<Boolean,RuntimeException> {
@Override public Boolean call() throws RuntimeException {
return Platform.isDarwin();
}
}

}

0 comments on commit 1957d3f

Please sign in to comment.