aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2011-12-05 17:26:29 +0200
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2011-12-05 17:26:29 +0200
commita5c345c2fd0d50eff90500061023c12b5ed9538c (patch)
tree7aa452b8e643f8dd51615933d2d9271a4e43a3c7
parent28ec9fb1db3d5ec6160a01c6836d277cd0dcb056 (diff)
Add perform() method from pristine CommandInterpreter class.
Have to be forked again, as does too much, so cannot be just subclassed.
-rw-r--r--src/main/java/hudson/plugins/shell/Shell.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/hudson/plugins/shell/Shell.java b/src/main/java/hudson/plugins/shell/Shell.java
index 346a124..efcef45 100644
--- a/src/main/java/hudson/plugins/shell/Shell.java
+++ b/src/main/java/hudson/plugins/shell/Shell.java
@@ -205,4 +205,43 @@ public class Shell extends CommandInterpreter {
}
private static final Logger LOGGER = Logger.getLogger(Shell.class.getName());
+
+ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, TaskListener listener) throws InterruptedException {
+ FilePath ws = build.getWorkspace();
+ FilePath script=null;
+ try {
+ try {
+ script = createScriptFile(ws);
+ } catch (IOException e) {
+ Util.displayIOException(e,listener);
+ e.printStackTrace(listener.fatalError(Messages.CommandInterpreter_UnableToProduceScript()));
+ return false;
+ }
+
+ int r;
+ try {
+ EnvVars envVars = build.getEnvironment(listener);
+ // on Windows environment variables are converted to all upper case,
+ // but no such conversions are done on Unix, so to make this cross-platform,
+ // convert variables to all upper cases.
+ for(Map.Entry<String,String> e : build.getBuildVariables().entrySet())
+ envVars.put(e.getKey(),e.getValue());
+
+ r = launcher.launch().cmds(buildCommandLine(script)).envs(envVars).stdout(listener).pwd(ws).join();
+ } catch (IOException e) {
+ Util.displayIOException(e,listener);
+ e.printStackTrace(listener.fatalError(Messages.CommandInterpreter_CommandFailed()));
+ r = -1;
+ }
+ return r==0;
+ } finally {
+ try {
+ if(script!=null)
+ script.delete();
+ } catch (IOException e) {
+ Util.displayIOException(e,listener);
+ e.printStackTrace( listener.fatalError(Messages.CommandInterpreter_UnableToDelete(script)) );
+ }
+ }
+ }
}