public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
return perform(build,launcher,(TaskListener)listener);
}
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)) );
}
}