cinderella

[unmaintained] simple CI engine
Log | Files | Refs | README | LICENSE

commit 184ff1f833af696513958603203f300e2a763b1c
parent 9ab00b0d398da8376606dc36e4498ed7c9a29f81
Author: Stefan Koch <programming@stefan-koch.name>
Date:   Mon, 23 Sep 2019 21:39:34 +0200

add status code to command output

Diffstat:
Msrc/execution.rs | 8+++++---
Msrc/lib.rs | 12++++++++++--
2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/execution.rs b/src/execution.rs @@ -10,7 +10,7 @@ pub enum ExecutionResult { NoExecution, Success, // failed command and its output - BuildError(String, String), + BuildError(String, String, Option<i32>), ExecutionError(String, String), } @@ -35,7 +35,7 @@ pub fn execute<W: Write>( let res = execute_pipeline(pipeline, &variables, stdout); match res { - ExecutionResult::BuildError(_, _) | ExecutionResult::ExecutionError(_, _) => { + ExecutionResult::BuildError(_, _, _) | ExecutionResult::ExecutionError(_, _) => { return res; }, _ => (), @@ -78,7 +78,9 @@ fn execute_pipeline<W: Write>( if !output.status.success() { return ExecutionResult::BuildError( String::from(format!("Pipeline failed in step: {}", cmd)), - outtext); + outtext, + output.status.code() + ); } } diff --git a/src/lib.rs b/src/lib.rs @@ -83,9 +83,17 @@ pub fn run(repo_ptr: &RepoPointer) { let res = execution::execute(&pipelines, &variables, &mut io::stdout()); match res { - ExecutionResult::BuildError(msg, output) | ExecutionResult::ExecutionError(msg, output) => { + ExecutionResult::BuildError(msg, output, code) => { + let code_msg = match code { + Some(code) => format!("Exited with status code: {}", code), + None => format!("Process terminated by signal") + }; let mailer = mail::build_mailer(&config.email); - mailer.send_mail(&format!("Build failed: {}\n{}", msg, output)); + mailer.send_mail(&format!("Build failed: {}\n{}\n\n{}", msg, code_msg, output)); + }, + ExecutionResult::ExecutionError(msg, output) => { + let mailer = mail::build_mailer(&config.email); + mailer.send_mail(&format!("Build failed: {}\n\n{}", msg, output)); }, _ => (), }