using System; using System.IO; using System.Text; using ln.build.commands; using ln.logging; namespace ln.build.pipeline { public static class CoreCommands { public static void ShellCommand(Stage stage,params string[] arguments) { CommandRunner commandRunner = new CommandRunner("/bin/bash", "-c", string.Format("\"{0}\"", string.Join(' ', arguments))) { Throw = CRThrow.NEVER, }; MemoryStream logStream = new MemoryStream(); int result = commandRunner.Run(stage.CommandEnvironment, logStream); stage.CommandEnvironment.Logger.Log(LogLevel.INFO, "command output:\n{0}", Encoding.UTF8.GetString(logStream.ToArray())); stage.CommandEnvironment.Logger.Log(LogLevel.INFO, "command exit code: {0}", result); if (result != 0) throw new Exception(String.Format("command exited with code {0} [0x{0:x}]", result)); return; } } }