private Object readResolve() throws ObjectStreamException { Shell shell = new Shell(command); shell.setUnstableReturn(unstableReturn); return shell; }
@Override public Builder newInstance(StaplerRequest req, JSONObject data) { return new Shell(data.getString("command")); }
@Override public Builder newInstance(StaplerRequest req, JSONObject data) { return new Shell(data.getString("command")); }
@Override public Builder newInstance(StaplerRequest req, JSONObject data) { return new Shell(data.getString("command")); }
private Object readResolve() throws ObjectStreamException { Shell shell = new Shell(command); shell.setUnstableReturn(unstableReturn); return shell; }
@Override public Builder newInstance(StaplerRequest req, JSONObject data) { return new Shell(data.getString("command"), data.getBoolean("disabled"), data.getString("description")); }
private CommandInterpreter createInterpreter(String scriptContent) { if (launcher.isUnix()) { return new Shell(scriptContent); } return new BatchFile(scriptContent); }
public boolean runCommandForResult(String command) throws InterruptedException, DebianizingException { announce("running command <{0}>", command); return new Shell(command).perform(build, launcher, listener); }
private int executeScriptContent(@Nonnull FilePath scriptExecutionRoot, @Nonnull String scriptContent, @Nonnull Map<String, String> scriptExecutionEnvVars) throws EnvInjectException { try { CommandInterpreter batchRunner; if (launcher.isUnix()) { batchRunner = new Shell(scriptContent); } else { batchRunner = new BatchFile(scriptContent); } FilePath tmpFile = batchRunner.createScriptFile(scriptExecutionRoot); logger.info(String.format("Executing and processing the following script content: %n%s%n", scriptContent)); int cmdCode = launcher.launch().cmds(batchRunner.buildCommandLine(tmpFile)).stdout(launcher.getListener()) .envs(scriptExecutionEnvVars).pwd(scriptExecutionRoot).join(); if (cmdCode != 0) { logger.info(String.format("Script executed. The exit code is %s.", cmdCode)); } else { logger.info("Script executed successfully."); } return cmdCode; } catch (IOException ioe) { throw new EnvInjectException("Error occurs on execution script file path", ioe); } catch (InterruptedException ie) { throw new EnvInjectException("Error occurs on execution script file path", ie); } }
private void addFingerprinterToProject(FreeStyleProject project, String[] contents, String[] files) throws Exception { StringBuilder targets = new StringBuilder(); for (int i = 0; i < contents.length; i++) { String command = "echo $BUILD_NUMBER " + contents[i] + " > " + files[i]; project.getBuildersList().add(Functions.isWindows() ? new BatchFile(command) : new Shell(command)); targets.append(files[i]).append(','); } project.getPublishersList().add(new Fingerprinter(targets.toString())); } }
public Result runScript(final ShellCommands commands) throws IOException, InterruptedException { Result r = Result.FAILURE; //Todo: use VitualChannel to figure out OS final String shellInterpreter = Functions.isWindows() ? "sh" : "/bin/bash"; final Run run = this.buildExecutionContext.getRun(); addExecutionInfoAction(run, commands); try { final Shell execution = new Shell("#!" + shellInterpreter + " -le \n" + commands.toShellScript()); if (this.buildExecutionContext.performStep(execution, this.listener)) { r = Result.SUCCESS; } } catch (final InterruptedException e) { r = Executor.currentExecutor().abortResult(); throw e; } finally { this.buildExecutionContext.setResult(r); } return r; }
batchRunner = new Shell(scriptContent); } else { batchRunner = new BatchFile(scriptContent);